使用spring boot —— maven构建
1.继承 starter parent
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.8.RELEASE</version> </parent>
2.如果你的系统pom已经有自定义的parent,又想使用springboot。还可以直接添加如下依赖:
<dependencyManagement> <dependencies> <!-- 这儿写其他依赖 --> <dependency> <!-- Import dependency management from Spring Boot --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.1.8.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
3. Spring Boot包含一个Maven插件,可以将项目打包为可执行jar。需要在pom中添加如下的<plugin>
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
4.springboot 提供了很多种starters,使用时只需要添加对应的依赖即可。