spring tomcat定时任务执行两次问题解决

 本地启动定时任务没问题,tomcat上会执行两次。原本的server.xml 如下,

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


        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
        <Context docBase="AutoEdus" path="" debug="0" reloadable="true" /> 

      </Host>

项目路径如下 

如果只更改server.xml,删除context节点,无效。

所以更改context的节点,docBase为空,同时删除ROOT目录

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


        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
        <Context docBase="" path="" debug="0" reloadable="true" /> 

      </Host>

 

posted @ 2022-03-14 19:06  明晓默  阅读(255)  评论(0编辑  收藏  举报