1. Modify the configuration file pom.xml
Add to jar in the form of packaged form
<packaging>jar</packaging>
2. Add the following in the build label content
finalname is packaged into a jar package name
You need to set the configuration of the main class, i.e. the class entry, sometimes not configured error.
<build> <finalName>Demo</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.2</version> <configuration> <mainClass>stdu.wys.DemoApplication</mainClass> </configuration> </plugin> </plugins> </build>
3.
Comprising a test class in src / test / java, SpringBootTest added in the annotation content,
@SpringBootTest (classes = {main class name .class})
4. In the right project at the run-> Maven build
Click on run
Then start packing, below the display after a successful appearance
5. Run
Generating jar package default directory on the target below, can be run directly
cd into the corresponding directory, the package can run the jar
java -jar Demo.jar