Java 使用@Scheduled spring注释时出现异常(找不到类[org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor])
我已使用Java 使用@Scheduled spring注释时出现异常(找不到类[org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor]),java,spring,maven,Java,Spring,Maven,我已使用@scheduled批注创建了一个计划作业。 看起来是这样的: package example.tools.rr; public class RequestProcessorJob { private RequestService requestService; ... @Scheduled(fixedRate = 10000) public void process() { ... } public Request
@scheduled
批注创建了一个计划作业。
看起来是这样的:
package example.tools.rr;
public class RequestProcessorJob {
private RequestService requestService;
...
@Scheduled(fixedRate = 10000)
public void process() {
...
}
public RequestService getRequestService() { return requestService; }
public void setRequestService(RequestService requestService) { this.requestService = requestService; }
}
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://www.eclipse.org/gemini/blueprint/schema/blueprint-compendium"
xmlns:ctx="http://www.springframework.org/schema/context" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://www.eclipse.org/gemini/blueprint/schema/blueprint-compendium http://www.eclipse.org/gemini/blueprint/schema/blueprint-compendium/gemini-blueprint-compendium.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.1.xsd
">
...
<bean id="handsetService" class="example.handset.impl.HandsetServiceImpl">
...
</bean>
<task:scheduler id="taskScheduler" />
<task:executor id="taskExecutor" pool-size="1" />
<task:annotation-driven executor="taskExecutor"
scheduler="taskScheduler" />
<bean class="example.tools.rr.RequestProcessorJob">
<cm:managed-properties persistent-id="example.handset.processing"
autowire-on-update="true" />
<property name="requestService" ref="handsetService" />
</bean>
</blueprint>
我已经把它放在一个bundle a中,所以我可以在其他bundle中使用这个类。我在bundle B中导入了它。B的blueprint.xml如下所示:
package example.tools.rr;
public class RequestProcessorJob {
private RequestService requestService;
...
@Scheduled(fixedRate = 10000)
public void process() {
...
}
public RequestService getRequestService() { return requestService; }
public void setRequestService(RequestService requestService) { this.requestService = requestService; }
}
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://www.eclipse.org/gemini/blueprint/schema/blueprint-compendium"
xmlns:ctx="http://www.springframework.org/schema/context" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://www.eclipse.org/gemini/blueprint/schema/blueprint-compendium http://www.eclipse.org/gemini/blueprint/schema/blueprint-compendium/gemini-blueprint-compendium.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.1.xsd
">
...
<bean id="handsetService" class="example.handset.impl.HandsetServiceImpl">
...
</bean>
<task:scheduler id="taskScheduler" />
<task:executor id="taskExecutor" pool-size="1" />
<task:annotation-driven executor="taskExecutor"
scheduler="taskScheduler" />
<bean class="example.tools.rr.RequestProcessorJob">
<cm:managed-properties persistent-id="example.handset.processing"
autowire-on-update="true" />
<property name="requestService" ref="handsetService" />
</bean>
</blueprint>
如果我添加了一个空类,该类在bundle B中只有一个@Scheduled
注释,那么一切正常,并且RequestProcessorJob被正确地调度(不使用空类,但它不会发生错误)
我尝试将模块A包含在pom.xml
中的B中,作为提供的以及编译
,结果是相同的
有一个reduntant类使其工作听起来并不是一个真正的解决方案。你对此有什么想法吗?这是一个bug,或者可能是某种奇怪的工作方式吗?好的,我只是缺少pom.xml中org.springframework.scheduling.annotation一节中的org.springframework.scheduling.annotation。毕竟很明显,但春天的行为在这里仍然很奇怪