Spring-boot-maven-plugin Plug-in action

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/hotdust/article/details/51404828

The "Org.springframework.boot:spring-boot-maven-plugin" plugin was added to the OM file. After the plugin is added, when the MVN package is run, it is packaged as a JAR file that can be run directly, and can be run directly using the "Java-jar" command. This simplifies the deployment of the application to a great extent, and only installs the JRE to run it.

You can specify whether a jar or war is generated in the POM.

<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
<!--...-->
<packaging>jar</packaging>
<!--...-->
</project>

You can also specify the class to execute, and if not specified, spring will find the class that has this " public static void main(String[] args) " method as an executable class.

If you want to specify, you can use the following two methods:

1, if your pom is inherited spring-boot-starter-parent, only need the following designation on the line.

<properties>    <!-- The main class to start by executing java -jar -->    <start-class>com.mycorp.starter.HelloWorldApplication</start-class></properties>

2, if your pom is not inherited spring-boot-starter-parent, you need the following designation.

    <plugin>      <groupId>org.springframework.boot</groupId>      <artifactId> spring-boot-maven-plugin</artifactid>      <version>1.3.5.RELEASE</version>      < configuration>        <mainClass>${start-class}</mainClass>        <layout>ZIP</layout>      </configuration>      <executions>        <execution>          <goals>            <goal> repackage</goal>          </goals>        </execution>      </executions>    </plugin >

Spring-boot-maven-plugin Plug-in action

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.