怎么实现将本地jar添加到Maven仓库
导读:本文共1555字符,通常情况下阅读需要5分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要:希望大家仔细阅读,能够学有所成!手动将本地jar添加到Maven仓库将jar添加到本地仓库的做法以下面pom.xml依赖的jar包为例:实际项目中pom.xml依赖写法:<dependency><groupId>org.springframework</groupId><artifactId>spring-context-support</... ...
目录
(为您整理了一些要点),点击可以直达。希望大家仔细阅读,能够学有所成!
以下面pom.xml依赖的jar包为例:
实际项目中pom.xml依赖写法:
Maven 安装 JAR 包的命令是:
例如我的这个spring-context-support-3.1.0.RELEASE.jar 文件放在了"D:\mvn\"中
则命令为:
-DgroupId=org.springframework
-DartifactId=spring-context-support
-Dversion=3.1.0.RELEASE
-Dpackaging=jar
注意:任何路径和名称不要有中文和空格,以防出现莫名其妙的错误。
还可以解决本地仓库是从别人那边复制的,但是需要的jar包中央仓库不存在,导致的执行package时出现以下异常
Failed to execute goal on project relayserver: Could not resolve dependencies for project com.xxx:xxx:war:1.0-SNAPSHOT: Failure to find xxx.xxx:xxx:jar:1.0 in http://maven.aliyun
.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus-aliyun has elapsed or updates are forced
假设将包htmlparser.jar放入了项目下的lib目录中 :
则pom.xml文件中依赖可以如下:
手动向maven库里面添加jar包,要以管理员身份进行添加,在jar包目录打开cmd
mvn install:install-file -Dfile=文件绝对路径 -DgroupId=maven仓库下面的路径 -DartifactId=jar包名-Dversion=jar包版本 -Dpackaging=jar -DgeneratePom=true
例如:
怎么实现将本地jar添加到Maven仓库的详细内容,希望对您有所帮助,信息来源于网络。