Springboot 使用maven 引用本地jar包 打包问题

1、开发的时候,可以使用maven 来引用其他的包,是最好的选择,但是很多时候,在对接其他的第三方接口的时候, 不能不适用第三方的jar,这个时候,很多人是选择,直接SystemPath的方式使用,如:

 <dependency>
	<groupId>com.sf</groupId>
	<artifactId>sf-novatar-log</artifactId>
	<version>1.09</version>
	<scope>system</scope>
	<systemPath>${project.basedir}/lib/sf-novatar-log-1.09.jar</systemPath>
 </dependency>

这样的方式,导入一个项目下面的一个jar,这个是可行的,至少是在开发工具上,是没用任何问题的

但是,在打包运行的是,就会出现,java.lang.ClassNotFoundException,  如图所示:

 这代表是,class编译的成功,但是运行时候,却找不到包。问题出在,打包的是,maven系统默认是不把《systemPath》的东西打包的,有点类似于:  <scope>provided</scope>;

要是使用,只需要添加以下的就可以了:但是,这个好像会导致本地启动找不到application.yml

  <build>
        <resources>
            <resource>
                <directory>${project.basedir}/lib</directory>
                <targetPath>BOOT-INF/lib/</targetPath>
                <includes>
                    <include>**/*.jar</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <targetPath>BOOT-INF/classes/</targetPath>
            </resource>
        </resources>
</build>

方法二:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <executable>true</executable>
        <includeSystemScope>true</includeSystemScope>
    </configuration>
</plugin>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值