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>
相关推荐
Kent_J_Truman1 天前
JDK Maven Tomcat Spring在VSCode中的部分配置细节(自用)
java·tomcat·maven
运维_攻城狮1 天前
Nexus 3.x 私服搭建与运维完全指南(Maven 实战)
java·运维·maven
chxii1 天前
Maven 详解(中)
java·maven
学到头秃的suhian1 天前
Maven
java·maven
菩提树下种菩提1 天前
Hadess零基础学习,如何管理Maven制品
maven·使用教程·hadess·国产开源制品管理工具·一文上手
小坏讲微服务1 天前
Docker-compose 搭建Maven私服部署
java·spring boot·后端·docker·微服务·容器·maven
chxii1 天前
Maven 详解(下)
java·maven
inferno1 天前
Maven基础(二)
java·开发语言·maven
杨武博1 天前
关于maven中pom依赖冲突问题记录
java·maven
码割机2 天前
Linux服务器安装jdk和maven详解
java·linux·maven