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 checkingUse 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 onsrc/main/java
, selectNew --> 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 selelectNew --> Class
- Follow the spring-guide to create the class.
网友评论