Java项目以配置文件的方式使用spring定时

来源:互联网 发布:小田切让的长相知乎 编辑:程序博客网 时间:2024/06/17 01:05


说一说遇上的坑:

  1、因为之前是使用了注解的方式实现定时,但是现在想要使用两套环境,所以改成了配置文件的形式。应为之前的

<task:annotation-driven />
写在别的配置文件里,没有清除,导致工程启动报Only one AsyncAnnotationBeanPostProcessor may exist within the context错误。删掉之前的就行了。

2、使用@Autowired来注入定时方法所在的类时,会报expected single matching bean but found 2 错误,改成

即可,或者使用

@Resource来代替
@Autowired@Qualifier("FontMediaBusiness")

阅读全文
0 0