Eclipse 上下文中只能存在一个AsyncAnnotationBeanPostProcessor
我有一个网络/核心模块项目。在我的Eclipse/STS环境中,即使应用程序在Tomcat中启动得很好,也会出现这样的错误“上下文中可能只存在一个AsyncAnnotationBeanPostProcessor”。 我觉得这不是一个真正的错误,但当它被识别出来时,它会导致在构建我的项目时出现问题,我想摆脱它 我很确定我不会多次导入包含任务的资源:annotation-driven executor=“myExecutor”scheduler=“myScheduler”,至少不会显式导入 我使用Quartz,但我没有使用@Scheduled,我通过xml创建计划bean。我确实在整个应用程序中使用@Async 我的web项目中有: web.xmlEclipse 上下文中只能存在一个AsyncAnnotationBeanPostProcessor,eclipse,spring,spring-mvc,Eclipse,Spring,Spring Mvc,我有一个网络/核心模块项目。在我的Eclipse/STS环境中,即使应用程序在Tomcat中启动得很好,也会出现这样的错误“上下文中可能只存在一个AsyncAnnotationBeanPostProcessor”。 我觉得这不是一个真正的错误,但当它被识别出来时,它会导致在构建我的项目时出现问题,我想摆脱它 我很确定我不会多次导入包含任务的资源:annotation-driven executor=“myExecutor”scheduler=“myScheduler”,至少不会显式导入 我使用Q
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/root-context.xml
/WEB-INF/security.xml
</param-value>
</context-param>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>dirAllowed</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
上下文配置位置
类路径:/root-context.xml
/WEB-INF/security.xml
调度员
org.springframework.web.servlet.DispatcherServlet
肮脏的
假的
上下文配置位置
/WEB-INF/dispatcher-servlet.xml
1.
root-context.xml
<import resource="classpath*:/spring/applicationContext-schedule.xml" />
<import resource="classpath*:/spring/applicationContext-ology.xml" />
<import resource="classpath*:/spring/applicationContext-mercadosa.xml" />
<import resource="classpath*:/spring/applicationContext-webapp.xml" />
<import resource="classpath*:/spring/applicationContext-ws.xml" />
<import resource="classpath*:/spring/applicationContext-services.xml" />
<import resource="classpath*:/spring/applicationContext.xml" />
<import resource="classpath*:/spring/applicationContext-transaction.xml" />
<import resource="classpath*:/spring/applicationContext-dao.xml" />
<import resource="classpath*:/spring/applicationContext-facet.xml" />
<import resource="classpath*:/spring/applicationContext-social.xml" />
applicationContext-scheduled.xml
<task:annotation-driven executor="myExecutor" scheduler="myScheduler"/>
<task:executor
id="myExecutor"
pool-size="5-10"
queue-capacity="25"
rejection-policy="CALLER_RUNS"/>
<task:scheduler id="myScheduler" pool-size="3"/>
<bean
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
....
</list>
</property>
<property name="quartzProperties" value="classpath:quartz.properties"/>
[....]
</bean>
....
[....]
核心和web中的test/resources/applicationContext-test.xml
<task:executor id="myExecutor" pool-size="5-10" queue-capacity="25" rejection-policy="CALLER_RUNS" />
测试资源不包含任何任务:注释驱动的语句
有什么建议吗
干杯,
马克你找到这个问题的解决办法了吗?这是因为在web应用程序中上下文多次初始化。我曾尝试仅通过root-context.xml导入带有任务的上下文xml,这是主要的应用程序上下文,但仍然面临这个问题。我尝试过,但不记得如何导入。需要考虑的一些想法:您是否确保组件扫描声明不会“重叠”?您的web目标目录中是否可能有一个已编译的项目?