maven project jar package

Transfer: https://www.cnblogs.com/jwentest/p/7586167.html

There are two ways to pack:

1. Direct  project -- right-click -- export , select JAR file package (this method is not recommended);

In this way, the package directly typed through java -jar  will prompt "no main manifest attribute", you need to modify the MANIFEST.MF file in the jar package , and add the line Main-Class

For details, please refer to: http://jingyan.baidu.com/article/db55b60990f6084ba30a2fb8.html

http://blog.chinaunix.net/uid-10376640-id-4621557.html

 

2. Packaged by maven command;

First of all, you need to determine the jdk version of the linux machine. The jar package created with the high version jdk cannot run on the low version linux environment. If the runtime prompts  Unsupported  major.minor version 52.0 , it is caused by the version problem, but you need to look at this Which package version is wrong before the prompt  

Source document < http://blog.sina.com.cn/s/blog_64ecfc2f0102uxu6.html >

If the JDK version on the linux machine is 1.7 , then the 1.7 version should be used when packaging;

 

The specific packaging steps are as follows:

a . Right-click the project --Run As --Maven build

 

b . Modify the JDK version under JRE

 

 

Goals in Main fill in clean package

 

 

c . Click Run to package, and you can see the path of the jar package from the log;

 

 

Remark:

a . The path of the project should preferably be in full English, without special symbols;

b . Turn off all related processes of the project path when packaging, such as opening the directory and opening the files in the directory to avoid failure during maven clean ;

Although there are thousands of people, I will go!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324890987&siteId=291194637