Only one AsyncAnnotationBeanPostProcessor may exist within the context 问题排查

启动tomcat时catalina.out中的错误日志:

1 22:14:29.161 [localhost-startStop-1] ERROR org.springframework.web.servlet.DispatcherServlet - Context initialization failed
2 org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Only one AsyncAnnotationBeanPostProcessor may exist within the context.
3 Offending resource: URL [jar:file:/usr/local/tomcat-xxx/lib/manage-nifi-group-1.0.0-SNAPSHOT.jar!/spring/controller/nifi-group.xml]
4         at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
5         at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
6         at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:72)
7         at org.springframework.scheduling.config.AnnotationDrivenBeanDefinitionParser.parse

定位到出问题的manage-nifi-group-1.0.0-SNAPSHOT.jar中的nifi-group.xml。

项目使用了spring定时器,上述配置文件中有 <task:annotation-driven scheduler=xxx />等定时器相关的配置。

百度错误原因,基本都集中在Spring的配置文件上,要么是<task:annotation-driven>标签重复,要么是文件头中如下内容重复:

<beans xmlns="http://www.springframework.org/schema/beans"
       .......
       xmlns:task="http://www.springframework.org/schema/task"
       xsi:schemaLocation=".........
                    http://www.springframework.org/schema/task
                    http://www.springframework.org/schema/task/spring-task-3.1.xsd
                    ">

 

在项目中仔细查验并未发现上述内容有重复配置的地方,于是继续翻看启动时的日志,发现在上面错误出现前,有以下内容:

1 22:43:55.319 [localhost-startStop-1] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Resolved classpath location [xxx/xxxx/xxxx/xxxx/xx/xxx/schedule/] to resources [URL [jar:file:/usr/local/tomcat-xxx/webapps/xxx/WEB-INF/lib/manage-nifi-group-1.0.0-SNAPSHOT.jar!/com/xxxx/xxxx/xxxx/xxxx/xxxx/schedule/], URL [jar:file:/usr/local/tomcat-xxxx/lib/manage-nifi-group-1.0.0-SNAPSHOT.jar!/com/xxxx/xxxx/xxxx/xxxx/idi/schedule/]]
2 22:43:55.319 [localhost-startStop-1] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Looking for matching resources in jar file [file:/usr/local/tomcat-xxx/webapps/manage-dataflow/WEB-INF/lib/manage-nifi-group-1.0.0-SNAPSHOT.jar]
3 22:43:55.320 [localhost-startStop-1] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Looking for matching resources in jar file [file:/usr/local/tomcat-xxx/lib/manage-nifi-group-1.0.0-SNAPSHOT.jar]

......

 

由此确定问题原因:同事误将manage-nifi-group-1.0.0-SNAPSHOT.jar上传到了tomcat的lib下,同时项目的lib下也有这个包,导致启动tomcat时这个包加载了两遍,Spring的task配置重复加载,从而出现该错误

 

posted on   每天都要好好睡觉  阅读(994)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示