Spring Boot Starter Parent Usage in Maven
I quite often see Spring Boot projects which are using the
spring-boot-starter-parent
as the following:
1<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3 <modelVersion>4.0.0</modelVersion>
4
5 <parent>
6 <groupId>org.springframework.boot</groupId>
7 <artifactId>spring-boot-starter-parent</artifactId>
8 <version>2.0.4.RELEASE</version>
9 <relativePath/>
10 </parent>
11
12 <properties>
13 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
15 <java.version>1.8</java.version>
16 </properties>
17 ...
18 <build>
19 <plugins>
20 <plugin>
21 <groupId>org.springframework.boot</groupId>
22 <artifactId>spring-boot-maven-plugin</artifactId>
23 </plugin>
24 </plugins>
25 </build>
26</project>
So far so good. Notices something? I have to mention that you can do it a little bit shorter like this:
1<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3 <modelVersion>4.0.0</modelVersion>
4
5 <parent>
6 <groupId>org.springframework.boot</groupId>
7 <artifactId>spring-boot-starter-parent</artifactId>
8 <version>2.0.4.RELEASE</version>
9 <relativePath/>
10 </parent>
11
12 ...
13 <build>
14 <plugins>
15 <plugin>
16 <groupId>org.springframework.boot</groupId>
17 <artifactId>spring-boot-maven-plugin</artifactId>
18 </plugin>
19 </plugins>
20 </build>
21</project>
The properties defined in the first example are already defined in the
spring-boot-starter-parent
pom file which means you do not need to define
them another time cause you inherit them via the parent.