跳至主要內容
浅谈Spring定时任务的使用(Scheduled注解)

环境说明

  使用maven3、Spring4.3构建、jdk7编译、运行在tomcat7.0中。

定时任务的基本配置

pom.xml:加入依赖

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
    <org.springframework.version>4.3.29.RELEASE</org.springframework.version>
  </properties>

  <dependencies>
    <!--SpringMVC依赖-->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>
  </dependencies>

ycyin大约 6 分钟SpringScheduled定时任务