Only one AsyncAnnotationBeanPostProcessor may exist
报错的前情提要:
- Spring MVC的上下文xml文件中添加了task的annotation:<task:annotation-driven/>
- 这个上下文xml文件名可能叫context.xml、applicationContext.xml等等*Context.xml
- 花了半小时搜索结果在StackOverflow上搜到了这个问题的描述
发生这个错误,表示在启动或执行的时候,在配置文件中出现了两次或两次以上的<task:annotation-driven/>,由于配置文件可能有多个,配置文件内可能还有相互引用:
有两个配置文件,applicationContext.xml中有task:annotation-driven/,testApplicationContext.xml中有<import resource=”A.xml” />
- 程序如果同时加载A和B,就会报错
- 程序如果加载A多次或者B多次,就会报错
排查一下配置文件是否有重复加载或相互引用,问题解决。