First of all, make sure that there are no errors in the program you wrote.
1. Packaging steps
1. General engineering
Click on the project structure=>Artifacts=>+Number=>JAR=>from models with dependencies...
Select main category
Modify Directory for META-INF/MANIFEST.MF:
The path is best to be at the same level as src, otherwise it is prone to problems. The author's actual test can also be placed in the resources folder.
Click OK
At this time, there will be a MANIFEST.MF file in the root directory of the project, which is a necessary file for the jar package. This file describes a lot of information about the Jar file, so I won’t give too much explanation here.
Finally Build Artifacts
The packaged jar file is in the out folder under the project root directory
2. Maven project
It is very user-friendly to use Maven directly for packaging.
Click on the right sidebar Maven=>Project name=>Lifecycle=>package=>Right click and select Run Maven Build
The packaged jar file is in the target folder under the project root directory
2. Run the jar package
Use command
java -jar xxx.jar
Spring boot has built-in Tomcat. When you see Tomcat start, it means that the jar package has run successfully (I set the Tomcat port to 8888, if you don’t set Tomcat’s default port to 8080)