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