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>
相关推荐
yurenpai(27届找实习中)2 小时前
从零读懂AI智能客服(二):Java 多模块项目如何协作:Maven 依赖、Spring 注入与运行时装配
java·spring·maven
deng12044 小时前
Maven多模块父子工程与IDEA导入异常排查记录
人工智能·maven·intellij-idea
相顾若初见4 小时前
RuoYi后端jar镜像制作
java·jar
深漂的华哥16 小时前
Ruoyi-Plus前后端分离场景下,数据加密传输
java·spring boot·后端·开源·maven·ruoyi
卓怡学长1 天前
w180springboot基于Java的悠扬乐器管理
java·spring boot·mysql·spring·maven·intellij-idea
早安试言1 天前
maven安装
java·maven
卓怡学长1 天前
w192基于springboot教务管理系统
java·数据库·spring boot·spring·maven·intellij-idea
栀栀栀栀栀栀1 天前
2026/8/23 maven springboot
java·spring boot·maven
EXI-小洲2 天前
MacOS 环境下 IntelliJ IDEA 的 Maven 配置指南
macos·maven·intellij-idea
evans在进步3 天前
Spring Boot 核心机制详解:可执行 JAR、CORS、静态资源与配置绑定
spring boot·后端·jar