Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
461 views
in Technique[技术] by (71.8m points)

java - What is best way to schedule task in spring boot application

I am current developing an application based on Spring-Boot.

I know that annotation like @Scheduled can schedule tasks. Since users in my application wanna send mails at different time and send only once.

I have already read the post Spring scheduling task - run only once, but it is weird always "new" an localExecutor in a Spring based application.

In that way , once a user schedule sending an email, I have to "new" an localExecutor for his task.

So , are there any better ways?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The simplest way to schedule tasks in Spring is to create method annotated by @Scheduled in spring managed bean. It also required @EnableScheduling in any @Configuration classes.

Spring tutorial


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...