xml ファイルのみで期待どおりに動作するスケジューラを 1 つ作成しました。しかし、これを Javaconfig クラスで実行することはできません。以下はコードです。
スケジューラ:
public class DemoServiceBasicUsageCron {
@Scheduled(cron="*/5 * * * * ?")
public void demoServiceMethod()
{
System.out.println("Method executed at every 5 seconds. Current time is :: "+ new Date());
}}
Java 構成:
@Configuration
public class TestCron {
@Bean
public DemoServiceBasicUsageCron demoCron() {
System.out.println(" bean created ");
return new DemoServiceBasicUsageCron();
}}
構成ファイルを次のように読んでいます
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestCron.class);
}
それが機能する可能性のある提案が必要でした。
よろしくサイ