Springboot 2, springboot
Create the Maven module of springboot.
For projects managed by Maven, we are still used to multiple modules. Adjust the project structure.
1. Modify the pom file of the springboot project.
1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4 <modelVersion>4.0.0</modelVersion> 5 6 <groupId>com.taynio.demo</groupId> 7 <artifactId>springboot</artifactId> 8 <version>0.0.1-SNAPSHOT</version> 9 <packaging>pom</packaging>10 11 <name>springboot</name>12 <description>Demo project for Spring Boot</description>13 14 <parent>15 <groupId>org.springframework.boot</groupId>16 <artifactId>spring-boot-starter-parent</artifactId>17 <version>1.3.3.RELEASE</version>18 <relativePath/> <!-- lookup parent from repository -->19 </parent>20 21 <properties>22 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>23 <java.version>1.8</java.version>24 </properties>25 26 <build>27 <plugins>28 <plugin>29 <groupId>org.springframework.boot</groupId>30 <artifactId>spring-boot-maven-plugin</artifactId>31 </plugin>32 </plugins>33 </build>34 35 </project>
Use the springboot project as a top-level project. On this basis, create the Maven Module Project web-rest module.
IntelliJ IDEA automatically adds a module declaration to the pom. xml file of our springboot project.
<Modules>
<Module> web-rest </module>
</Modules>
2. Modify the pom. xml file of the web-rest project.
1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 <modelVersion>4.0.0</modelVersion> 6 7 <parent> 8 <artifactId>springboot</artifactId> 9 <groupId>com.taynio.demo</groupId>10 <version>0.0.1-SNAPSHOT</version>11 </parent>12 <artifactId>web-rest</artifactId>13 <packaging>jar</packaging>14 15 <dependencies>16 <dependency>17 <groupId>org.springframework.boot</groupId>18 <artifactId>spring-boot-starter-web</artifactId>19 </dependency>20 21 <dependency>22 <groupId>org.springframework.boot</groupId>23 <artifactId>spring-boot-starter-test</artifactId>24 <scope>test</scope>25 </dependency>26 </dependencies>27 28 <build>29 <plugins>30 <plugin>31 <groupId>org.springframework.boot</groupId>32 <artifactId>spring-boot-maven-plugin</artifactId>33 </plugin>34 </plugins>35 </build>36 37 </project>
3. Create a SpringBoot Startup Program.
Create a Java class: com. taynio. demo. springboot. SpringbootWebRestApplication:
1 package com.taynio.demo.springboot; 2 3 import org.springframework.boot.SpringApplication; 4 import org.springframework.boot.autoconfigure.SpringBootApplication; 5 6 /** 7 * Created by Zhantao on 2016/3/24. 8 * Date:2016/3/24 15:28 9 * Email:10 */11 @SpringBootApplication12 public class SpringbootWebRestApplication {13 14 public static void main(String[] args) {15 SpringApplication.run(SpringbootWebRestApplication.class, args);16 }17 18 }
Run. The web-rest project module is successfully created.