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>
相关推荐
小短腿乄4 小时前
IDEA将本地的JAR文件手动安装到 Maven的本地仓库
maven·intellij-idea·jar
WMSmile6 小时前
Maven下载aspose依赖失败的解决方法
java·maven
2401_897930066 小时前
Maven 使用教程
java·maven
weixin_456588157 小时前
【Spring Boot】Maven中引入 springboot 相关依赖的方式
spring boot·后端·maven
字节王德发21 小时前
如何在SpringBoot中通过@Value注入Map和List并使用YAML配置?
java·maven·intellij-idea
weixin_456588151 天前
【Maven】特殊pom.xml配置文件 - BOM
xml·java·maven
bjzhang751 天前
如何创建一个父类 Maven项目,然后在父类下再创建子项目,构建多模块 Maven 项目
java·maven
lyrhhhhhhhh1 天前
Maven进阶
java·maven
豆沙沙包?1 天前
7.学习笔记-Maven进阶(P75-P89)-进度(p75-P80)
笔记·学习·maven