maven 手动安装jar包
仓库位置
本地仓库位置
E:mozqapache-maven-3.6.1
epo
默认仓库位置
C:Users1.m2
epository
修改方式
<localRepository>E:mozqapache-maven-3.6.1
epo</localRepository>
参数
安装指定文件到本地仓库命令:mvn install:install-file
-Dmaven.repo.local 仓库位置
-DgroupId=<groupId>
-DartifactId=<artifactId>
-Dversion=1.0.0 版本号
-Dpackaging=jar 打包方式
-Dfile=<myfile.jar> jar文件位置
示例
# 注意:需要合并为一行
mvn install:install-file
-Dmaven.repo.local=E:mozqapache-maven-3.6.1
epo
-DgroupId=org.apache.poi
-DartifactId=poi
-Dversion=3.10.1
-Dpackaging=jar
-Dfile=E:mozqapache-maven-3.6.1jarspoi-3.10.1.jar
需要安装 poi 的jar包到自己设置的仓库
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10.1</version>
</dependency>
安装到默认的仓库
mvn install:install-file -DgroupId=org.apache.poi -DartifactId=poi -Dversion=3.10.1 -Dpackaging=jar -Dfile=E:mozqapache-maven-3.6.1jarspoi-3.10.1.jar
C:Users1>mvn install:install-file -DgroupId=org.apache.poi -DartifactId=poi -Dversion=3.10.1 -Dpackaging=jar -Dfile=E:mozqapache-maven-3.6.1jarspoi-3.10.1.jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing E:mozqapache-maven-3.6.1jarspoi-3.10.1.jar to C:Users1.m2
epositoryorgapachepoipoi3.10.1poi-3.10.1.jar
[INFO] Installing C:Users1AppDataLocalTempmvninstall4839632845182773472.pom to C:Users1.m2
epositoryorgapachepoipoi3.10.1poi-3.10.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.436 s
[INFO] Finished at: 2019-10-25T09:41:03+08:00
[INFO] ------------------------------------------------------------------------
错误:
Installing E:mozqapache-maven-3.6.1jarspoi-3.10.1.jar to C:Users1.m2
epositoryorgapachepoipoi3.10.1poi-3.10.1.jar
发现安装到了系统默认的仓库。
安装到指定的仓库
# -Dmaven.repo.local 指定仓库位置
-Dmaven.repo.local=E:mozqapache-maven-3.6.1
epo
# 安装到了指定本地仓库
[INFO] Installing E:mozqapache-maven-3.6.1jarspoi-3.10.1.jar to E:mozqapache-maven-3.6.1
epoorgapachepoipoi3.10.1poi-3.10.1.jar
C:Users1>mvn install:install-file -Dmaven.repo.local=E:mozqapache-maven-3.6.1
epo -DgroupId=org.apache.poi -DartifactId=poi -Dversion=3.10.1 -Dpackaging=jar -Dfile=E:mozqapache-maven-3.6.1jarspoi-3.10.1.jar
[INFO] Scanning for projects...
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing E:mozqapache-maven-3.6.1jarspoi-3.10.1.jar to E:mozqapache-maven-3.6.1
epoorgapachepoipoi3.10.1poi-3.10.1.jar
[INFO] Installing C:Users1AppDataLocalTempmvninstall2352554239287225355.pom to E:mozqapache-maven-3.6.1
epoorgapachepoipoi3.10.1poi-3.10.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.866 s
[INFO] Finished at: 2019-10-25T09:54:56+08:00
[INFO] ------------------------------------------------------------------------
maven从网络安装jar到本地仓库
工具
maven-dependency-plugin插件
pom.xml文件
案例
mvn dependency:get
-Dartifact=org.apache.jena:jena-iri:3.14.0 指定要下载的artifact
-s E:mozqapache-maven-3.6.1confsettings.xml 指定maven的setttings文件
-Dmaven.wagon.http.ssl.insecure=true 防止https问题
-Dmaven.wagon.http.ssl.allowall=true 防止https问题
-Dmaven.wagon.http.ssl.ignore.validity.dates=true 防止https问题
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mozq.dubbo</groupId>
<artifactId>demo-01-provider</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
</dependencies>
<repositories>
<repository>
<id>maven_mozq</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
</repositories>
</project>
E: 0>mvn dependency:get -Dartifact=org.apache.jena:jena-iri:3.14.0 -s E:mozqapache-maven-3.6.1confsettings.xml -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.mozq.dubbo:demo-01-provider >-------------------
[INFO] Building demo-01-provider 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:get (default-cli) @ demo-01-provider ---
[INFO] Resolving org.apache.jena:jena-iri:jar:3.14.0 with transitive dependencies
Downloading from maven-central: http://central.maven.org/maven2/org/apache/jena/jena-iri/3.14.0/jena-iri-3.14.0.pom
Downloading from aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/jena/jena-iri/3.14.0/jena-iri-3.14.0.pom
Downloaded from aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/jena/jena-iri/3.14.0/jena-iri-3.14.0.pom (4.3 kB at 6.4 kB/s)
Downloading from maven-central: http://central.maven.org/maven2/org/apache/jena/jena-iri/3.14.0/jena-iri-3.14.0.jar
Downloading from aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/jena/jena-iri/3.14.0/jena-iri-3.14.0.jar
Downloaded from aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/jena/jena-iri/3.14.0/jena-iri-3.14.0.jar (137 kB at 357 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.199 s
[INFO] Finished at: 2020-01-21T09:02:53+08:00
[INFO] ------------------------------------------------------------------------
bugs
dependency:get必须指定一个artifact
PS C:Users1> mvn dependency:get
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:get (default-cli) @ standalone-pom ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.580 s
[INFO] Finished at: 2020-01-21T08:26:33+08:00
[INFO] ------------------------------------------------------------------------
# 错误信息
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:get (default-cli) on project standalone-pom: You must specify an artifact, e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0 -> [Help 1]
The goal you specified requires a project必须指定一个pom
PS C:Users1> mvn dependency:get -Dartifact=org.apache.jena:jena-iri:jar:3.14.0 -Dmaven.multiModuleProjectDirectory=$MAVEN_HOME -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.067 s
[INFO] Finished at: 2020-01-21T08:33:24+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:Users1). Please verify you invoked Maven from the correct directory. -> [Help 1]
org.apache.jena:jena-iri:jar:3.14.0组件的名称写错不应该包含jar
E: 0>mvn dependency:get -Dartifact=org.apache.jena:jena-iri:jar:3.14.0 -s E:mozqapache-maven-3.6.1confsettings.xml -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.mozq.dubbo:demo-01-provider >-------------------
[INFO] Building demo-01-provider 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:get (default-cli) @ demo-01-provider ---
[INFO] Resolving org.apache.jena:jena-iri:3.14.0:jar with transitive dependencies
Downloading from maven-central: http://central.maven.org/maven2/org/apache/jena/jena-iri/jar/jena-iri-jar.pom
Downloading from aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/jena/jena-iri/jar/jena-iri-jar.pom
Downloading from boundlessgeo: https://repo.boundlessgeo.com/main/org/apache/jena/jena-iri/jar/jena-iri-jar.pom
[INFO] Failure detected.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.571 s
[INFO] Finished at: 2020-01-21T08:36:15+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:get (default-cli) on project demo-01-provider: Couldn't download artifact: Unable to get dependency information for org.apache.jena:jena-iri:3.14.0:jar: Failed to retrieve POM for org.apache.jena:jena-iri:3.14.0:jar: Could not transfer artifact org.apache.jena:jena-iri:pom:jar from/to maven-central (http://central.maven.org/maven2/): Failed to transfer file http://central.maven.org/maven2/org/apache/jena/jena-iri/jar/jena-iri-jar.pom with status code 501
[ERROR] org.apache.jena:jena-iri:3.14.0:jar
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] maven-central (http://central.maven.org/maven2/, releases=true, snapshots=true),
[ERROR] aliyun (http://maven.aliyun.com/nexus/content/groups/public/, releases=true, snapshots=true),
[ERROR] boundlessgeo (https://repo.boundlessgeo.com/main/, releases=true, snapshots=true),
[ERROR] maven_mozq (http://maven.aliyun.com/nexus/content/groups/public/, releases=true, snapshots=true),
[ERROR] alimaven (http://maven.aliyun.com/nexus/content/groups/public/, releases=true, snapshots=false)
[ERROR] Path to dependency:
[ERROR] 1) org.apache.maven.plugins:maven-downloader-plugin:jar:1.0
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException访问阿里云仓库是https的报错
[ERROR] Plugin .apache.jena:jena-iri:jar or one of its dependencies could not be resolved: Failed to read artifact descriptor for .apache.jena:jena-iri:jar:jar: Could not transfer artifact .apache.jena:jena-iri:pom:jar from/to alimaven (http://maven.aliyun.com/nexus/content/groups/public/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]