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>
相关推荐
kevinfkq21 小时前
Java-idea编辑器中Jar方式打包启动
java·intellij-idea·jar
夫唯不争,故无尤也1 天前
Maven创建Java项目实战全流程
java·数据仓库·hive·hadoop·maven
weixin_404551241 天前
openrewrite Maven plugin configuration
java·maven·configuration·openrewrite
FIavor.1 天前
Cannot resolve plugin org.apache.maven.plugins:maven-jar-plugin:3.2.2 这怎么办
maven·apache·jar
zjjuejin2 天前
Maven 云原生时代面临的八大挑战
java·后端·maven
雨过天晴而后无语2 天前
Windchill的codebase目录打成jar
java·jar
摆烂且佛系3 天前
IDEA Maven 仓库配置优先级
github·maven·intellij-idea
momo_via3 天前
maven下载与安装及在IDEA中配置maven
java·maven·intellij-idea
李贺梖梖3 天前
Maven 设置项目编码,防止编译打包出现编码错误
java·maven
洛克大航海3 天前
Ubuntu安装JDK与Maven和IntelliJ IDEA
ubuntu·jdk·maven·intellij idea