Maven
Maven users can inherit spring-boot-starter-parent
the project to get suitable default settings. This parent project provides the following features:
- The default compilation level is Java 1.6
- Source code encoded as UTF-8
- A dependency management node that allows you to omit labels for common dependencies
<version>
, inherited fromspring-boot-dependencies
POM. - Appropriate resource filtering
- Appropriate plugin configuration ( exec plugin , surefire , Git commit ID , shade )
- Resource filtering for
application.properties
andapplication.yml
One last note: since default configuration files receive Spring-style placeholders ( ${...}
), Maven filtering uses @..@
placeholders instead (you can use Maven properties resource.delimiter
to override this).
Inherit from starter parent
To configure your project inheritance spring-boot-starter-parent
simply set parent
to:
<!-- Inherit defaults from Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.BUILD-SNAPSHOT</version>
</parent>
Note : You should only need to specify the Spring Boot version on this dependency. If importing other starters, you can safely omit the version number.
Using Spring Boot without a parent POM
Not everyone likes to inherit spring-boot-starter-parent
POM. You may need to use a company standard parent, or you may prefer to declare all Maven configuration explicitly.
If you don't , you still get the benefits of dependency management spring-boot-starter-parent
by using a dependency:scope=import
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.3.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
change java version
spring-boot-starter-parent
Choose a fairly conservative Java compatibility strategy. If you follow our advice and use a recent Java version, you can add a java.version
property:
<properties>
<java.version>1.8</java.version>
</properties>
Using the Spring Boot Maven plugin
Spring Boot includes a [Maven plugin](…/VIII. Build tool plugins/58. Spring Boot Maven plugin.md), which can package the project into an executable jar. If you want to use it, you can add the plugin to <plugins>
the node:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Note : If using the Spring Boot starter parent pom, you only need to add the plugin without configuring it, unless you want to change settings defined in the partent.