我已經創建了一個彈簧啓動計劃任務,如link中所述。當我運行該應用程序時,它只是開始和停止,並且我沒有看到指南中提到的輸出。日誌下面春季啓動計劃任務自行關閉
2015-10-19 17:54:14.366 INFO 4512 --- [lication.main()] o.litmos.workday.batch.app.Application : Starting Application on RohitNagesh-PC with PID 1118
2015-10-19 17:54:14.418 INFO 4512 --- [lication.main()] s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]84cebe: startup date [Mon Oct 19 17:54:14 IST 2015]; root of context hierarchy
2015-10-19 17:54:14.790 INFO 4512 --- [lication.main()] o.s.b.f.xml.XmlBeanDefinitionReader : Loading XML bean definitions from class path resource [applicationContext.xml]
2015-10-19 17:54:15.088 INFO 4512 --- [lication.main()] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.scheduling.annotation.SchedulingConfiguration' of type [class org.springframework.scheduling.annotation.SchedulingConfiguration$$EnhancerBySpringCGLIB$$3770f0ed] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-19 17:54:15.258 INFO 4512 --- [lication.main()] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2015-10-19 17:54:15.279 INFO 4512 --- [lication.main()] o.litmos.workday.batch.app.Application : Started Application in 1.184 seconds (JVM running for 5.503)
2015-10-19 17:54:15.366 INFO 4512 --- [ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.spring[email protected]84cebe: startup date [Mon Oct 19 17:54:14 IST 2015]; root of context hierarchy
2015-10-19 17:54:15.367 INFO 4512 --- [ Thread-1] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
如何才能使任務運行無盡,直到我停止它?
下面的添加
@SpringBootApplication
@EnableScheduling
@ImportResource("applicationContext.xml")
public class Application {
public static void main(String[] args) {
System.out.println("Batch Started");
SpringApplication.run(Application.class);
}
}
@Component
public class SampleJob {
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
@Scheduled(fixedRate = 5000)
public void reportCurrentTime() {
System.out.println("The time is now " + dateFormat.format(new Date()));
}
}
的pom.xml
<dependencies>
<!-- Spring Batch dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>1.2.7.RELEASE</version>
</dependency>
</dependencies>
你可以發佈你的當前代碼? – ESala
你是否完全按照指南完成了工作,或者或多或少地遵循了指南......在我看來,就好像你在主要班級沒有'@ EnableScheduling'。 –
我已添加我的當前代碼 – rohit