Spring Boot POM Detailed

Source: Internet
Author: User
Tags solr glassfish spring boot actuator gemfire log4j



As this picture shows, in the Spring IO framework, Spring boot is in the execution layer to see the official explanation for this layer:


The Spring IO execution layer provides domain-specific runtimes (DSRs) for applications built on the IO Foundation modules . A DSR may run standalone without requiring deployment to an external container.


Or cite the official words to illustrate what spring boot does primarily:


Spring Boot reduces the effort needed to create Production-ready, devops-friendly, Xml-free Spring applications. It simplifies bootstrapping of Spring projects with minimal code, implements an extensible set of operational features suc h as automated health checking and metrics endpoints, and supports embedded containers enabling the creation of Self-conta ined executables.

Take a look at some of the key words here:


Production-ready,devops-friendly-mainly focused on the Spring Boot actuator module, providing on-line monitoring of operations related features such as health checking,metrics endpoints, or by providing self-contained executables such as Maven exec, or something like the one jar.


Xml-free-pre-defined a lot of annotation, configuring meta-programming styles.

Spring boot gives me a feeling more like a devops platform in the spring community, integrating and delivering features such as dependency management, deployment automation, and monitoring operations.


Ok, here's the main part of the story. Next, let's analyze how spring boot is organization-dependent. Take a look at the POM structure of its project code.


The first is the root directory of the Pom, such as:

  <groupId>org.springframework.boot</groupId><artifactId>spring-boot-build</artifactId> <version>1.2.1.build-snapshot</version><packaging>pom</packaging><name>spring Boot build</name>

Very concise, in addition to declaring the Antrun,surefire and Replacer plug-ins, it defines three profiles including Default,integration,ci. There are several points to pay attention to:

1. The default profile declares a series of minimum dependent modules, as follows:

<modules>        <module>spring-boot-dependencies</module>        <module>spring-boot-parent </module>        <module>spring-boot-versions</module>        <module>spring-boot-tools</ module>        <module>spring-boot</module>        <module>spring-boot-autoconfigure</module >        <module>spring-boot-actuator</module>        <module>spring-boot-docs</module>        <module>spring-boot-starters</module>        <module>spring-boot-cli</module>      </modules>

This relationship, especially the parent-child module relationship, is described later.


2. You can focus on Com.google.code.maven-replacer-plugin this plugin, mainly to do property file replacement, and Alibaba Open source Antx maven plugin somewhat similar. Of course, if you're passionate about the filter mechanism of MAVEN's resources, I'm sure you'll prefer this replacer plugin.


Let's take a look at the parent-child module relationship mentioned above, Spring-boot-dependencies is a parent pom, which is configured as follows:

<groupId>org.springframework.boot</groupId>  <artifactid>spring-boot-dependencies</ artifactid>  <version>1.2.1.BUILD-SNAPSHOT</version>  <packaging>pom</packaging >

It enforces the MAVEN version, such as:
<prerequisites>    <maven>3.0.2</maven>  </prerequisites>

And a bunch of dependencies are declared with dependencymanagement, such as:

<properties> <!--Spring Boot--<spring-boot.version>1.2.1.build-snapshot</spring-boot.versi On> <!--third party--<activemq.version>5.10.0</activemq.version> <aspectj.version> 1.8.4</aspectj.version> <atomikos.version>3.9.3</atomikos.version> <bitronix.version> 2.1.4</bitronix.version> <commons-beanutils.version>1.9.2</commons-beanutils.version> < Commons-collections.version>3.2.1</commons-collections.version> <commons-dbcp.version>1.4</ Commons-dbcp.version> <commons-dbcp2.version>2.0.1</commons-dbcp2.version> < Commons-digester.version>2.1</commons-digester.version> <commons-pool.version>1.6</ Commons-pool.version> <commons-pool2.version>2.2</commons-pool2.version> <crashub.version> 1.3.0</crashub.version> <dropwizard-metrics.version>3.1.0</dropwizard-metrics.version> <flyway.version>3.0</flyway.version> <freemarker.version>2.3.21</ Freemarker.version> <gemfire.version>7.0.2</gemfire.version> <glassfish-el.version>3.0.0 </glassfish-el.version> <gradle.version>1.6</gradle.version> <groovy.version>2.3.8</ Groovy.version> <gson.version>2.3</gson.version> 

The question is, how does spring test and manage these non-spring ecosystem dependencies? At present I have not found the official has this aspect of the explanation, if have found, please leave a message to tell me.

In addition to the Declaration of the jar dependency, the Pom also to maven common plugin made a declaration of dependency, using the MAVEN version plugin students will feel that this is a good habit, right. In addition, there is a plugin git-commit-id-plugin need to pay extra attention, the use of BuildNumber plugin students may well understand the function of plugin.


Finally take a look at the spring-boot-parent, which is a level two parent Pom, such as:



Focus on a few points to note:

1. Mixed use of dependencymanagement and dependencies, this is what I like more.


2. It is also important to configure the lifecyclemappingmetadata of the ORG.ECLIPSE.M2E plug-in in detail, which is a boon for those who have introduced the project to eclipse through Maven project.


3. The use of Maven-enforcer-plugin plug-in, this is what I prefer, the current rules are relatively simple, such as:

<rules><requireJavaVersion><version> (1.7,) </version></requireJavaVersion>< Requireproperty><property>main.basedir</property></requireproperty><requireproperty ><property>project.organization.name</property></requireProperty><requireProperty> <property>project.name</property></requireProperty><requireProperty><property> Project.description</property></requireproperty></rules>

See Enforcers official documentation for more details, https://maven.apache.org/enforcer/enforcer-rules/https://maven.apache.org/enforcer/enforcer-rules/

4. The use of the Maven-jar-plugin plugin is useful for tools that are compatible with the Java Package API.

Ok,spring Boot Pom is basically about this, hopefully this article will help those who aspire to build their own top Pom team.


Reference documents:

http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#getting-started-introducing-spring-boot

Spring Boot POM Detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.