美文网首页
2018-07-19 Building Spring-Sched

2018-07-19 Building Spring-Sched

作者: 猪迹 | 来源:发表于2018-07-19 14:04 被阅读0次

Step 1 Create a Maven project with Spring-Tool-Suite

  • Select File --> New --> Maven Project
  • Check Create a simple project(skip archetype selection). Then select the work-space for your project, which may be an empty folder you created manually for the project. Or you can use the default location by checking Use default Workspace location
  • Click Next
  • Input [Group Id], [Artifact Id] for the project.

    One example may be 'Group Id = com.mycompany.hello' & 'Artifact Id = st_a'

  • Click Finish to let Spring-Tool-Suite` to build the project for you.

Step 2 Configure the pom.xml for you project

  • Initially, the pom.xml automatically generated may contain content like
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.hello</groupId>
  <artifactId>st_a</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</project>
  • Add below section to declare a parent-project for it.
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
    </parent>
  • Add dependency section to include Spring-boot
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
    </dependencies>
  • Add build section to include spring build plug-in
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

Step 3 Create a package inside the project

  • In the Project Explorer, right click on src/main/java, select New --> Package from the context-menu
  • Input name for the package, like 'hello', then click Finish
  • The coming steps are straight-forward, just follow the referenced guide and finish the task.

Step 4 Add the scheduled task class

  • Right-click on the hello package just created, and selelect New --> Class
  • Follow the spring-guide to create the class.

Reference

相关文章

网友评论

      本文标题:2018-07-19 Building Spring-Sched

      本文链接:https://www.haomeiwen.com/subject/wsszpftx.html