maven引用本地jar包,不能将本地jar打包

说明

有时需要通过maven引入本地jar,本地运行时没有问题,打包成应用jar时出现ClassNotFound异常

通过排查发现本地引入的jar,实际并没有打包到应用jar里

方案

引入本地Jar

        <dependency>
        <groupId>XXXClient</groupId>
        <artifactId>XXXClient</artifactId>
        <version>1.1</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/lib/XXXClient.jar</systemPath>
    </dependency>

为spring-boot-maven-plugin设置includeSystemScope为true

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <executable>false</executable>
        <includeSystemScope>true</includeSystemScope>
    </configuration>
</plugin>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容