Create executable JAR
We can also complete our example by creating an executable jar file that runs in production via the plugin.
First introduce dependencies:
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
Open the cmd command in the project directory and use the mvn package command to package, as follows:
If you want to view the internal directory of the packaged jar file, you can use the command jar tvf target/myproject-0.0.1-SNAPSHOT.jar to view the directory structure;
Use java -jar target\spring-boot-hello-1.0-SNAPSHOT.jar to start the application as follows:
The test results are as demonstrated in 3.4;
If you encounter an error that there is no main manifest directory at startup, please see: http://www.cnblogs.com/lfalex0831/p/8967428.html
Copyright statement: This article is an original article by the blogger, please indicate the source for reprinting, thank you!