Spring计划的cron作业在预定时间内运行两次。
使用spring 4.2.5版本。
REST API - >泽西+春天整合。
web.xml如下。
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>REST-Service-Servlet</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.provider.packages</param-name>
<param-value>RESTController</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>com.om.ResponseCorsFilter</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>REST-Service-Servlet</servlet-name>
<url-pattern>/api/*</url-pattern>
任务条目的spring application context xml文件。
<task:annotation-driven/>
Spring bean如下。
@Component("springBean")
public class SpringBean {
@Scheduled(cron = "0 35 23 * * ?")
public void job() {....}
答案 0 :(得分:0)
感谢您的帮助。问题解决了。
解决方案:我正在加载两次相同的bean,因此删除了重复的bean。