Spring Boot Maven Package executable jar file!

Source: Internet
Author: User

Maven Pom.xml must contain

[Plain]View PlainCopy
    1. <packaging>jar</packaging>

[HTML]View PlainCopy
  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.springframework.boot</groupId>
  5. <artifactid>spring-boot-maven-plugin</artifactid>
  6. <configuration>
  7. <fork>true</fork>
  8. </configuration>
  9. </plugin>
  10. </plugins>
  11. </Build>



Full Pox.xml

[HTML]View PlainCopy
  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi= "http://www.w3.org/2001 /xmlschema-instance "
  2. xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
  3. <modelversion>4.0.0</modelversion>
  4. <groupId>com.feedback</groupId>
  5. <artifactid>feedback-service</artifactid>
  6. <version>0.1.0</version>
  7. <packaging>jar</packaging>
  8. <properties>
  9. <java.version>1.8</java.version>
  10. </Properties>
  11. <parent>
  12. <groupId>org.springframework.boot</groupId>
  13. <artifactid>spring-boot-starter-parent</artifactid>
  14. <version>1.3.0.release</version>
  15. </Parent>
  16. <dependencies>
  17. <!--Spring boot --
  18. <dependency>
  19. <groupId>org.springframework.boot</groupId>
  20. <artifactid>spring-boot-starter-web</artifactid>
  21. </Dependency>
  22. <dependency>
  23. <groupId>org.springframework.boot</groupId>
  24. <artifactid>spring-boot-starter-data-jpa</artifactid>
  25. </Dependency>
  26. <!--MySQL database --
  27. <dependency>
  28. <groupId>mysql</groupId>
  29. <artifactid>mysql-connector-java</artifactid>
  30. </Dependency>
  31. <!--Commons-lang --
  32. <dependency>
  33. <groupId>commons-lang</groupId>
  34. <artifactid>commons-lang</artifactid>
  35. <version>2.6</version>
  36. </Dependency>
  37. </Dependencies>
  38. <!--jar --
  39. <build>
  40. <plugins>
  41. <plugin>
  42. <groupId>org.springframework.boot</groupId>
  43. <artifactid>spring-boot-maven-plugin</artifactid>
  44. <configuration>
  45. <fork>true</fork>
  46. </configuration>
  47. </plugin>
  48. </plugins>
  49. </Build>
  50. </Project>



Go to the project directory to run: MVN clean Package

The jar is generated in the target folder under the project directory

The resulting jar file is in the: D:\programmer\eclipse\feedback-service\target folder

Java-jar run the jar package to

Java-jar using an external configuration file when running the jar package application.properties

Execute jar under Linux

[Plain]View PlainCopy
    1. Nohup Java-xmx512m-xms512m-djava.security.egd=/dev/urandom-jar Message-service-1.0-snapshot.jar >/dev/null 2 >&1 &

Linux also has a special file/dev/null, it is like a bottomless pit, all the information redirected to it will disappear into a trace.

>/dev/null 2>&1

Note: The order here cannot be changed, otherwise the desired effect is not achieved, the standard output is redirected to/dev/null, then the standard error is redirected to standard output, and the standard error is redirected to/dev/null because the standard output has been redirected to/dev/null. So everything was quiet:-)

Spring Boot Maven Package executable jar file!

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.