第一種情況可能是spring掃描了兩次
比如spring-config\spring-mvc都掃描了改定時任務麸折,則更改spring-mvc配置的掃描路徑過濾定時調(diào)度
<context:component-scan base-package="com.test">
<context:exclude-filter type="annotation" expression="org.springframework.scheduling.annotation.EnableScheduling"/>
</context:component-scan>
第二種情況可能是tomcat配置導致容器被初始化兩次
由于web項目直接放在tomcat的webapp下奕坟,并且通過根路徑訪問孕暇,配置如下
<Context path="" docBase="..\.." debug="0" reloadable="true"/>
查找類似問題處理方式:
方法1:在conf/Catalina/localhost生成test.xml【推薦】
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<Context antiResourceLocking="false" privileged="true" useHttpOnly="true" path="/" docBase="..\.." >
<!--
Remove the comment markers from around the Valve below to limit access to
the manager application to clients connecting from localhost
-->
<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
</Context>
方法2:不配置根路徑訪問
方法3:將路徑已出webapp目錄蜓氨,在docBase中指定路徑(可以是相對于webapp的路徑圆恤,或者絕對路徑)
方法4:替換ROOT目錄