项目依赖的一个jar包是在开发环境的maven 私有仓库获取的,在部署的环境中没法获取到,所以采取了将jar包放在项目目录下,pom中添加本地依赖的方式
1 通过scope:system引入
把jar包放在根目录下的lib包中,添加依赖
1 <dependency> 2 <groupId>**</groupId> 3 <artifactId>x</artifactId> 4 <version>2.2-SNAPSHOT</version> 5 <scope>system</scope> 6 <systemPath>${project.basedir}/lib/**.x.2.2-SNAPSHOT.jar</systemPath> 7 </dependency>
使用这种方式不可行,因为 scope:system和scope:system的依赖范围作用相同,即对于编译和测试classpath有效,运行时无效
2 将jar包装载到本地仓库
命令:
1 mvn install:install-file 2 -Dfile=<path-to-file> 3 -DgroupId=<group-id> 4 -DartifactId=<artifact-id> 5 -Dversion=<version> 6 -Dpackaging=<packaging> 7 -DgeneratePom=true 8 9 Where: <path-to-file> the path to the file to load 10 <group-id> the group that the file should be registered under 11 <artifact-id> the artifact name for the file 12 <version> the version of the file 13 <packaging> the packaging of the file e.g. jar
pom依赖
<dependency> <groupId>**</groupId> <artifactId>x</artifactId> <version>2.2-SNAPSHOT</version> </dependency>
这样就可以在编译、测试、运行时都能被加载到
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)