引入了第三方jar 的maven项目打包运行不了

 

在项目中增加lib文件,将第三方的jar导入其中,然后pom.xml加上  ,此时项目就可以运行了,但是如果要打包项目成jar,还需要下一步骤!

<dependency>
   <groupId>com.okcoin.commons</groupId>
   <artifactId>okex-java-sdk-api</artifactId>
   <version>v0.1</version>
   <scope>system</scope>
   <systemPath>${project.basedir}/lib/okex-java-sdk-api.jar</systemPath>
</dependency>

 

 

 

打包插件这里要加上configuration 这一步骤,然后运行maven的clean和package命令打包后就会把你外部引入的jar包打包到你的项目中了。

 

<!--将第三方jar打包到项目-->
<configuration>
   <includeSystemScope>true</includeSystemScope>
</configuration>

 

 

 

 

https://blog.csdn.net/weixin_42047118/article/details/87484288

Maven项目中,我们可以通过以下几种方式将第三方本地JAR文件引入到war包中: 1. 通过 system scope 引入:在项目的pom.xml文件中,添加如下配置: ```xml <dependency> <groupId>com.example</groupId> <artifactId>example</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>${project.basedir}/libs/example.jar</systemPath> </dependency> ``` 这种方式直接指定了本地JAR文件的路径,并将其作为系统路径引入。 2. 通过 systemPath 引入:在系统的pom.xml文件中,添加如下配置: ```xml <dependencies> ... <dependency> <groupId>com.example</groupId> <artifactId>example</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>/path/to/example.jar</systemPath> </dependency> ... </dependencies> ``` 与第一种方式类似,也是通过指定本地JAR文件的路径进行引入。 3. 通过 install 到本地仓库引入:首先需要使用以下命令将本地JAR文件安装到本地Maven仓库中: ``` mvn install:install-file -Dfile=/path/to/example.jar -DgroupId=com.example -DartifactId=example -Dversion=1.0 -Dpackaging=jar ``` 在项目的pom.xml文件中,添加如下配置: ```xml <dependencies> ... <dependency> <groupId>com.example</groupId> <artifactId>example</artifactId> <version>1.0</version> </dependency> ... </dependencies> ``` 这种方式会将本地JAR文件安装到Maven本地仓库中,然后从本地仓库中引入。 无论使用哪种方式,都需要在pom.xml文件中添加相应的依赖配置,以确保Maven能够正确地将第三方本地JAR文件打包进入war包中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值