SpringBoot official documentation to learn (ii) build system using Spring Boot

  It is strongly recommended that you choose a support for dependency management and can be used to publish "Maven Central" warehouse build system. We recommend that you select Maven or Gradle. Other building systems (for example, Ant) can also be used with Spring Boot, but they are not well supported.

  1. Dependency Management

  Each Spring Boot version provides a list of all dependencies it supports. In fact, you do not need to build a dependency provide versions of these configurations, since Spring Boot manages the version for you. When you upgrade Spring Boot itself, these dependencies will be upgraded in a consistent manner.

  Tip: You can still specify a version, and cover the recommended Spring Boot when needed.

  Dependency list contains all spring and Spring Boot modules can be used with third-party libraries and improve the list. This list is made available as ( spring-boot-dependencies) list of criteria for use with Maven and Gradle.

  Tips: Spring Boot each release are associated with a basic version of the Spring Framework. It is strongly recommended that you do not specify its version.

  2.Maven

  Maven user can choose from  spring-boot-starter-parent to get reasonable defaults project inheritance. Parent Project offers the following features:

  • Java 1.8 is the default compiler.
  • UTF-8 encoded source.
  • Dependency management section, pom inherited from spring-boot-dependencies, and to manage public version dependencies. When these dependencies own pom may be omitted <version> tags for these dependencies.
  • repackageTarget execution has  repackage executed ID.
  • Reasonable resource filter.
  • Reasonable plug-in configuration ( Exec pluginGit the commit ID , and  Shade ).
  • Application.properties and application.yml for files containing specific configuration of rational resource filter.

  Note that, since the document acceptance application.properties and application.yml Spring style placeholder ($ {...}), and therefore the filter has been changed to use Maven @ .. @ placeholder. (You can override it by setting a property named resource.delimiter of Maven.)

  3. inherit Starter Parent

  To configure project inherited from the spring-boot-starter-parent, parent set as follows:

<!-- Inherit defaults from Spring Boot -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.8.RELEASE</version>
</parent>

  Tips: As long as the dependencies for Spring Boot specify a version number, if you import other starters, you can safely omit the version number.

  With this setting, you can also cover the various dependencies in the project by covering their own property. For example, to upgrade to Spring Data released another series, you can add the following to the pom.xml:

<properties>
    <spring-data-releasetrain.version>Fowler-SR2</spring-data-releasetrain.version>
</properties>

  4. In the case where no Parent POM Spring Boot

  Not everyone likes inherited from the spring-boot-starter-parent POM. You may need to use a standard where their parent companies, or may wish to explicitly declare all the Maven configuration.

  If you do not want to use spring-boot-starter-parent, still you can use  scope=import to preserve the benefits of dependency management (rather than plug-in management) dependencies, as follows:

<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>

  As described above, the foregoing example is provided to allow you to use to cover the respective attribute dependencies. In order to obtain the same result, the need to add an entry dependencyManagement before spring-boot-dependencies entry project. For example, to upgrade to Spring Data released another series, the following elements can be added to the pom.xml:

<dependencyManagement>
    <dependencies>
        <!-- Override Spring Data release train provided by Spring Boot -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-releasetrain</artifactId>
            <version>Fowler-SR2</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <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>

  Tips: In the previous example, we specify the BOM, you can cover any type of dependency in the same way.

  5. Spring Boot Maven widget

  Spring Boot contain a Maven plugin, items can be packaged as an executable jar. If you are using plug-ins, add it to your project's pom.xml <plugins> section, as shown in the following example:

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

 

  Tip: If you use parent pom Spring Boot starters, you can simply add plug-ins. Unless you want to change the settings defined in the parent, otherwise you do not need to configure it.

 

Guess you like

Origin www.cnblogs.com/improver/p/SpringBoot.html