The reason why tomcat loads the code twice and how to deal with it

Problem phenomenon: Every time tomcat is started, the Java code will be loaded twice. If there is a timer-like business, the timer will also have two copies running, which will affect the business.

         mm.war is under tomcat/webapps . The configuration of tomcat/conf/server.xml is as follows:

<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">

         <Context path="" docBase="mm" reloadable="false" />

</Host>

         After Tomcat starts, it will automatically decompress mm.war into mm folder.

In this way , appBase="webapps" in Host will make tomcat load all directories under tomcat/webapps , including mm . The access path is http://192.168.0.1/mm .

The docBase="mm" in the Context will make tomcat load the mm directory under the webapp , and the access path is: http://192.168.0.1/ . 

It is equivalent to loading a project twice.

 

 

Solution: delete the Context node

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326211640&siteId=291194637