解读Spring Boot的pom.xml

一 Spring Boot的父级依赖

1 代码示例

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.7.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

2 解读

添加Spring Boot的父级依赖,这样当前项目就是Spring Boot项目了。

spring-boot-starter-parent是一个特殊的starter,它用来提供相关的Maven默认依赖,使用它之后,常用包依赖可以省去version标签。

关于Spring Boot提供了哪些jar包的依赖,针对本例1.3.7.RELEASE版本,可查看maven仓库的下面文件。

D:\.m2\repos\org\springframework\boot\spring-boot-dependencies\1.3.7.RELEASE\spring-boot-dependencies-1.3.7.RELEASE.pom.

展示代码片段

二 怎样添加一个依赖

示例——添加Web支持的starter pom

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

三 怎样添加Spring Boot的编译插件

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

猜你喜欢

转载自blog.csdn.net/chengqiuming/article/details/81813049