The method actually used in the thin package and jar package project

<plugins>
            <!--采用瘦jar包的方式, 方便进行局部jar包的更新-->
            <!--注意 启动时需要增加参数 -Dloader.path=./lib-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>com.major.ServiceAutoConfig</mainClass>
                    <layout>ZIP</layout>
                    <!-- 需要包含的jar包 -->
                    <includes>
                        <!-- 不包含任何jar包 -->
                        <include>
                            <groupId>nothing</groupId>
                            <artifactId>nothing</artifactId>
                        </include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- 将第三方jar包拷贝到lib目录下 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                                    
                       <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

This code is the configuration file of the Maven project, which mainly configures two plug-ins:

  1. spring-boot-maven-plugin: Used to package Spring Boot applications into executable JAR files. Among them, the mainClass attribute specifies the main class of the application, the layout attribute specifies the packaging format (here is ZIP), and the includes attribute specifies the dependent libraries that need to be included (here does not contain any dependent libraries).

  2. maven-dependency-plugin: used to copy the third-party library that the project depends on to the lib directory of the project. Among them, the outputDirectory attribute specifies the output directory as ${project.build.directory}/lib.

Guess you like

Origin blog.csdn.net/qq_22905801/article/details/131113374