我使用sprint boot 1.3,spring 4.2
在这堂课上
@Service
public class PaymentServiceImpl implements PaymentService {
....
@Transactional
@Override
public void processPayment() {
List<Payment> payments = paymentRepository.findDuePayment();
processCreditCardPayment(payments);
}
}
Run Code Online (Sandbox Code Playgroud)
我想每隔x刻拨打一次processPayment.
此x时刻在数据库中设置.用户可以修改它.
所以我想我不能使用anotation.
我开始这样做了
@EntityScan(basePackageClasses = {MyApp.class, Jsr310JpaConverters.class})
@SpringBootApplication
@EnableCaching
@EnableScheduling
public class MyApp {
@Autowired
private DefaultConfigService defaultConfigService;
public static void main(String[] args) {
SpringApplication.run(MyApp.class, args);
}
@Bean
public TaskScheduler poolScheduler() {
SimpleAsyncTaskExecutor taskScheduler = new SimpleAsyncTaskExecutor();
DefaultConfigDto defaultConfigDto = defaultConfigService.getByFieldName("payment-cron-task");
String cronTabExpression = "0 0 4 * * ?";
if (defaultConfigDto != …Run Code Online (Sandbox Code Playgroud)