maven工程中引入外部jar

1、引入模块下的jar

1.负责打包的模块,pom中加上这个插件,这个可以把外部jar包打入工程中。

复制代码
<!-- 打包 -->
<build>
	<finalName>xxx-send-admin</finalName>
		<resources>
			<resource>
				<directory>${project.basedir}/lib</directory>
				<targetPath>BOOT-INF/lib/</targetPath>
				<includes>
				<include>**/*.jar</include>
				</includes>
			</resource>
			<!--将src/main/resources下的文件打包进去,否则运行jar程序会报错不能启动-->
			<resource>
				<directory>src/main/resources</directory>
			</resource>
		</resources>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
			<configuration>
			<includeSystemScope>true</includeSystemScope>
		</configuration>
		</plugin>
		<!-- 跳过单元测试 -->
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-surefire-plugin</artifactId>
			<configuration>
			<skipTests>true</skipTests>
			</configuration>
		</plugin>
	</plugins>
</build>

2.应用jar包的模块pom

复制代码
<dependency>
   <groupId>com.fin-framwork</groupId>
   <artifactId>fin-framework-client-1.0.0-SNAPSHOT</artifactId>
   <version>1.0.0</version>
   <type>jar</type>
   <scope>system</scope>
   <systemPath>${project.basedir}/lib/fin-framework-client-1.0.0-SNAPSHOT.jar</systemPath>
</dependency>

3.Jar包位置图

2、引入非本模块下的jar

复制代码
<dependency>
    <groupId>com.aa.bb</groupId>
    <artifactId>xxxx-client</artifactId>
    <scope>system</scope>
 	<systemPath>${project.basedir}/../lib/xxxx-client-1.0.0.jar</systemPath>
    <version>1.0.0</version>
</dependency>
相关推荐
想进大厂的小徐14 小时前
maven的子模块和子pom的区别
java·maven
Samson Bruce15 小时前
【Maven Spring Nacos之profile】
maven
Skilce1 天前
ZrLog 高可用部署
运维·服务器·数据库·阿里云·maven
福运常在2 天前
股票数据API(21)如何获取股票指数最新分时交易数据
java·python·maven
Riu_Peter2 天前
【技术】Maven 配置 settings.xml 轮询下载
xml·java·maven
ChaseDreamRunner2 天前
如何用 NSSM 把 Jar 做成 Windows 服务
java·windows·jar
中国胖子风清扬3 天前
实战:基于 Camunda 8 的复杂审批流程实战指南
java·spring boot·后端·spring·spring cloud·ai·maven
zb200641203 天前
Spring Boot spring-boot-maven-plugin 参数配置详解
spring boot·后端·maven
圣光SG3 天前
Maven 学习笔记(基础入门版)
笔记·maven
deelless3 天前
IDEA maven项目添加本地jar包
maven·intellij-idea·jar