Solon v3.0.3

开发计划任务 Job 指南

</> markdown

开发计划任务,我们可以在 solon-lib 的基础上,添加一个 Solon Scheduling 实现插件(比如:solon-scheduling-simple)

<parent>
    <groupId>org.noear</groupId>
    <artifactId>solon-parent</artifactId>
    <version>3.0.3</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.noear</groupId>
        <artifactId>solon-lib</artifactId>
    </dependency>
    
    <dependency>
        <groupId>org.noear</groupId>
        <artifactId>solon-scheduling-simple</artifactId>
    </dependency>
</dependencies>

简单的示例:

@EnableScheduling
@Component
public class App {
    public static void main(String[] args) {
        Solon.start(App.class, args);
    }

    @Scheduled(fixedRate = 1000 * 3)
    public void job1() {
        System.out.println("Hello job1: " + new Date());
    }

    @Scheduled(cron = "1/2 * * * * ? *")
    public void job2() {
        System.out.println("Hello job2: " + new Date());
    }
}

开发指南: