欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

spring boot 打包引入第三方jar

程序员文章站 2024-01-28 11:56:16
...

目录

有时候我们需要的jar在maven里不存在,需要手动引入。比如,钉钉sdk

<dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>taobao-sdk-java</artifactId>
            <version>1.0.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/libs/taobao-sdk-java-auto_1479188381469-20180831.jar</systemPath>
</dependency>

springboot在打包的时候,调用spring-boot-maven-plugin,执行repackage把tomcat和resource,lib等合成一个新的jar。想要将系统jar打进去,必须配置includeSystemScope。最终会将lib放入BOOT-INF\lib

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>build-info</goal>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>