Spring cloud project packaged tripartite jar summary (both compiled with maven and jar package under lib)

Spring cloud project packaged and used

<!-- 普通项目不掺杂第三方lib下jar使用-->
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <executable>true</executable>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.1.6.RELEASE</version>
            <configuration>
                <classifier>exec</classifier>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Take this part as an example (groupId, artifactId, version are free to fill in, systemPath is the file path)

<dependency>
    <groupId>xpyun</groupId>
    <artifactId>opensdk</artifactId>
    <version>1.0</version>
    <systemPath>${
    
    project.basedir}/src/main/resources/lib/xpyun-opensdk.jar</systemPath>
    <scope>system</scope>
</dependency>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.1.6.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- 如下配置(完美)解决lib下jar打包问题-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <resources>
                        <resource>
                            <directory>${
    
    project.basedir}/src/main/resources/lib</directory>
                            <targetPath>BOOT-INF/lib/</targetPath>
                            <includes>
                                <include> **/*.jar</include>
                            </includes>
                        </resource>
                        <resource>
                            <directory>${project.basedir}/src/main/resources</directory>
                            <targetPath>BOOT-INF/classes/</targetPath>
                        </resource>
                    </resources>
                </configuration>
            </plugin>
        </plugins>

Guess you like

Origin blog.csdn.net/qq_34117294/article/details/111580165