Maven Pom.xml must contain
[Plain]View PlainCopy
- <packaging>jar</packaging>
[HTML]View PlainCopy
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactid>spring-boot-maven-plugin</artifactid>
- <configuration>
- <fork>true</fork>
- </configuration>
- </plugin>
- </plugins>
- </Build>
Full Pox.xml
[HTML]View PlainCopy
- <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" >
- <modelversion>4.0.0</modelversion>
- <groupId>com.feedback</groupId>
- <artifactid>feedback-service</artifactid>
- <version>0.1.0</version>
- <packaging>jar</packaging>
- <properties>
- <java.version>1.8</java.version>
- </Properties>
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactid>spring-boot-starter-parent</artifactid>
- <version>1.3.0.release</version>
- </Parent>
- <dependencies>
- <!--Spring boot --
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactid>spring-boot-starter-web</artifactid>
- </Dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactid>spring-boot-starter-data-jpa</artifactid>
- </Dependency>
- <!--MySQL database --
- <dependency>
- <groupId>mysql</groupId>
- <artifactid>mysql-connector-java</artifactid>
- </Dependency>
- <!--Commons-lang --
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactid>commons-lang</artifactid>
- <version>2.6</version>
- </Dependency>
- </Dependencies>
- <!--jar --
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactid>spring-boot-maven-plugin</artifactid>
- <configuration>
- <fork>true</fork>
- </configuration>
- </plugin>
- </plugins>
- </Build>
- </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
- 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!