StringMVC定时任务执行两次,Tomcat启动时myThreadPoolTaskExecutor、getExecutor初始化两遍

StringMVC定时任务执行两次,Tomcat启动时myThreadPoolTaskExecutor、getExecutor初始化两遍
是<context:component-scan>配置问题
<br/>
修改前:

````
<!-- 开启自动扫包 -->
<context:component-scan
  base-package="com.web">
  <!--制定扫包规则,不扫描@Controller注解的JAVA类,其他的还是要扫描 -->
  <context:exclude-filter type="annotation"
                          expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
````
```
<!-- 开启自动扫包 -->
<context:component-scan
  base-package="com.web.*">
  <!--制定扫包规则,不扫描@Controller注解的JAVA类,其他的还是要扫描 -->
  <context:exclude-filter type="annotation"
                          expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
```


修改后:


````
<!-- 开启自动扫包 -->
<context:component-scan
  base-package="com.web.controller">
  <!--制定扫包规则,不扫描@Controller注解的JAVA类,其他的还是要扫描 -->
  <context:exclude-filter type="annotation"
                          expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
````

猜你喜欢

转载自blog.csdn.net/qq_36538368/article/details/125300216
今日推荐