1. Common jar package packaging methods.
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <mainClass>com.imooc.security.StartWeb</mainClass> <!--Specify the main method executed by jar--> <addClasspath>true</addClasspath> <!--Configure the lib package read path--> <classpathPrefix>lib/</classpathPrefix><!--The path is lib/; *must be consistent with the outputDirectory path output below--> </manifest> </archive> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory> ${project.build.directory}/lib <!--Output the jar package that the project depends on, under the lib folder of the project compilation root path--> </outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> <finalName>security</finalName> <!--final name of jar output --> </build>
The path effect is as follows:
lib folder:
2. SpringBoot project packaging method, package the lib package into the project at the end of jar.
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> <finalName>security-core</finalName> </build>