Your Site Title

tomcat

开启监控

tomcat-users.xml

<role rolename="manager-gui"/>
<role rolename="manager-jmx"/>
<user username="hbzw2023" password="hbzw2023#3202" roles="manager-gui, manager-jmx"/>

内存优化

startup.sh

export CATALINA_OPTS=" -server -Dfile.encoding=UTF-8 -Xms4096m -Xmx4096m -XX:PermSize=256M -XX:MaxNewSize=256m -XX:MaxPermSize=1024m "

连接优化

<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
    maxThreads="500" 
    minSpareThreads="50"        prestartminSpareThreads="true" 
    maxQueueSize="1000" />

<!-- A "Connector" represents an endpoint by which requests are received
     and responses are returned. Documentation at :
     Java HTTP Connector: /docs/config/http.html
     Java AJP  Connector: /docs/config/ajp.html
     APR (HTTP/AJP) Connector: /docs/apr.html
     Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
           address="192.168.2.110"
           executor="tomcatThreadPool"               
           protocol="org.apache.coyote.http11.Http11NioProtocol"
           connectionTimeout="20000"
           redirectPort="8443" />

允许ip访问

server.xml

Connector 中添加address
::1 是IPV6
192.168.2.100, 192.168.2.101 可以多个

安全

<security-constraint>
    <web-resource-collection>
            <web-resource-name>govern-web</web-resource-name>
            <url-pattern>/*</url-pattern>
			<http-method>PUT</http-method>
			<http-method>DELETE</http-method>
			<http-method>HEAD</http-method>
			<http-method>OPTIONS</http-method>
			<http-method>TRACE</http-method>
    </web-resource-collection>
    <auth-constraint></auth-constraint>

</security-constraint>

spring tomcat

<servlet>
	<servlet-name>spring</servlet-name>
	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
	<init-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext-mvc.xml</param-value>
	</init-param>
	<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
	<servlet-name>spring</servlet-name>
	<url-pattern>/</url-pattern>
</servlet-mapping>

Reference