1. Add the following code to the POM.xml file; Note: I later searched and added the three tags version, configuration, and executions. The online solution is either not available or different. I tried it, and I must have these three tags;
2. If there is no version tag, an error will be reported when generated.
3. If the jar generated without configuration and executions tags will report that the jar has no home directory listing error;
After a day of grief, no one can let himself be Xiaobai. Another idea: the packaged tab page must have;
<packaging>jar</packaging><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</ artifactId><version>2.0.3.RELEASE</version><configuration><mainClass>${start-class}</mainClass></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></execution></plugin></plugins></build>4. At the beginning, I saw other tutorials using the eclipse cocoa visualization page to generate jars. I don’t know why I just couldn’t use their method. After running them, I reported that the javaw.exe in the jdk directory has been terminated. Later, I didn’t find a solution, so I used the command line. There is no problem with using commands to execute, but later I didn’t care about it, just use commands, which is quite convenient. Let me write down the steps to execute using commands; I executed it under win10;
1. Run cmd to open blackface;
2. Switch the directory to your own project and directory, and then run the mvn package command; the following appears will be successful;
Note that the previous ones are all info, and the yellow ones are wrong, and you have forgotten what the error message is;
The error in this step was because of the pom.xml configuration file problem; it was fine after I changed it to my own configuration above, but I searched for that configuration for a long time and found it on the official website. This is the URL: https://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html. Actually, I don’t understand it, I just look at the configuration file;
3. After the execution is completed, the jar file will be generated in the target directory: the following picture is mine
4. After successful generation, it is run. The running method is to enter the target directory and run the java -jar file name command, and then run it; let’s take a picture;
If you run here, if a jar does not have a home directory listing, the value is because of the pom.xml configuration file problem; I can't do it according to other people's methods, but later I changed the configuration file, and the final content of the configuration file is above; I'm giving a secondary picture below;
Summarize
The above is the perfect solution to the spring boot package jar jar that the editor introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!