The problem that SpringMVC is initialized twice

   After the project is deployed to the production server, it is found that the bean of a timer task is executed twice in a row at the specified time. Adding log debugging found that this bean was initialized twice, and further adding log debugging found that the Web startup class, that is, the subclass of AbstractAnnotationConfigDispatcherServletInitializer, was also executed twice. When testing in the IDE of the development environment, this phenomenon does not exist. Therefore, it is suspected that it is a problem with Tomcat, but the version of the development environment is the same as that of the production environment, and only the root path of Tomcat has been modified in the development environment.
   Reference: The method provided by http://www.lxway.com/206659492.htm:
quote
Method 1: Do not configure root path access
Method 2: Remove the path from the webapp directory, and specify the path in docBase (it can be a path relative to the webapp, or an absolute path) [Recommended]
Method 3: Replace the ROOT directory [Recommended]
Method 4 : Generate ROOT.xml in conf/Catalina/localhost and add the following:
<?xml version='1.0' encoding='utf-8'?>
 <Context docBase="xxx" path="" reloadable="true" />


According to method 3, after making adjustments, the problem is solved.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326773052&siteId=291194637