Maven依赖包问题解决-could not resolve artifact/Missing artifact

用MAVEN自动化管理项目固然好,但是对于依赖问题是一个头痛的问题,特别对于newbaby,
当我们SVN检查项目会出现以下问题
[color=red]could not resolve artifact
Missing artifact org.apache.httpcomponents:fluent-hc:jar:4.3.6
Missing artifact com.jhlabs:imaging:jar:01012005[/color]
这些问题都是依赖包不能从仓库中,下载所致,这要归功于国家了,生在这个国家,做开发,悲哀,别悲伤,我们有解决办法:
一般
1.clean project
2.mvn clean
3.右击项目maven-》update project,并选择强制更新;


如果上面无法解决:
加仓库:
<repositories>
<repository>
<id>atlassian</id>
<name>atlassian</name>
<url>http://maven.jahia.org/maven2/</url>
</repository>
<repository>
<id>com.springsource.repository.maven.release</id>
<url>http://maven.springframework.org/release/</url>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>oracleReleases</id>
<name>Oracle Released Java Packages</name>
<url>http://download.oracle.com/maven</url>
</repository>
<repository>
<id>JBossRepo1</id>
<name>Jboss1</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</repository>
<repository>
<id>JBossRepo</id>
<name>Jboss</name>
<url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
</repository>
</repositories>

删除maven本地仓库依赖包对应的文件夹,maven-》update project

仍不能解决:
0.下载相应的jar包,手动安装
1.删除maven本地仓库依赖包对应的文件夹
2.先进入DOS,再进入jar所在的目录
3.执行命令
mvn install:install-file -Dfile=fluent-hc-4.3.6.jar -DgroupId=org.apache.httpcomponents -DartifactId=fluent-hc -Dversion=4.3.6 -Dpackaging=jar

参数说明:
-Dfile:jar包文件名带后缀
-DgroupId:组织id
-DartifactId:artifact Id
-Dversion:版本
-Dclassifier:环境一般为JDK
-Dpackaging:包类型
4.更新项目:maven-》update project
实例:
E:\mvnjar>mvn install:install-file -Dfile=imaging-01012005.jar -DgroupId=com.jhlabs -DartifactId=imaging -Dversion=01012005 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ standalone-pom ---
[INFO] Installing E:\mvnjar\imaging-01012005.jar to D:\.m2\repository\com\jhlabs\imaging\01012005\imaging-01012005.jar
[INFO] Installing C:\Users\donald\AppData\Local\Temp\mvninstall7803684983644843844.pom to D:\.m2\repository\com\jhlabs\imaging\01012005\imaging-01012005.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.591s
[INFO] Finished at: Tue Aug 16 16:47:39 CST 2016
[INFO] Final Memory: 2M/15M
[INFO] ---------------------------------------
对应POM
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
<scope>provided</scope>
<version>4.3.6</version>
</dependency>

带classifier的依赖包
mvn install:install-file -Dfile=Dm7JdbcDriver-7.1.3.204-jdk16.jar -DgroupId=com.dameng -DartifactId=Dm7JdbcDriver -Dversion=7.1.3.204 -Dclassifier=jdk16 -Dpackaging=jar


对应的POM,-Dclassifier为环境标识
<dependency>
<groupId>com.dameng</groupId>
<artifactId>Dm7JdbcDriver</artifactId>
<version>7.1.3.204</version>
<classifier>jdk16</classifier>
<scope>test</scope>
</dependency>


下面一般是其他jar的依赖包
mvn install:install-file -Dfile=httpcore-4.3.3.jar -DgroupId=org.apache.httpcomponents -DartifactId=httpcore -Dversion=4.3.3 -Dpackaging=jar


mvn install:install-file -Dfile=imaging-01012005.jar -DgroupId=com.jhlabs -DartifactId=imaging -Dversion=01012005 -Dpackaging=jar
[INFO] Scanning for projects... Downloading from dg-artifact: https://cmc.centralrepo.rnd.huawei.com/maven/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml Downloading from artifact-plugins: https://dgg.maven.repo.cmc.tools.huawei.com/artifactory/BPIT-public-maven/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml [WARNING] Could not transfer metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml from/to artifact-plugins (https://dgg.maven.repo.cmc.tools.huawei.com/artifactory/BPIT-public-maven/): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target [WARNING] Could not transfer metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml from/to dg-artifact (https://cmc.centralrepo.rnd.huawei.com/maven/): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.365 s [INFO] Finished at: 2025-06-10T20:31:09+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies could not be resolved: [ERROR] Failed to resolve version for org.apache.maven.plugins:maven-archetype-plugin:jar:RELEASE: Could not find metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml in local (C:\04_DevTools\maven_repo2) [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following
最新发布
06-11
### Maven maven-archetype-plugin PKIX path building failed 问题解决方案 在使用Maven插件 `maven-archetype-plugin` 时,如果遇到证书路径错误(PKIX path building failed)和依赖无法解析的问题,通常是因为SSL证书验证失败导致的。以下是解决问题的详细方法: #### 方法一:忽略SSL证书验证 可以通过在Maven运行参数中添加以下选项来忽略SSL证书验证[^3]: ```bash -Dmaven.wagon.http.ssl.insecure=true \ -Dmaven.wagon.http.ssl.allowall=true \ -Dmaven.wagon.http.ssl.ignore.validity.dates=true ``` 将这些参数添加到IDEA的Maven设置中(例如,在VIM Options位置),或者直接在命令行运行Maven命令时附加这些参数。 #### 方法二:导入正确的SSL证书 如果忽略SSL证书验证不是理想的选择,可以尝试导入正确的SSL证书到Java的信任库中。具体步骤如下: 1. 下载目标仓库的SSL证书(例如从浏览器中导出)。 2. 使用以下命令将证书导入到Java的信任库中: ```bash keytool -import -trustcacerts -keystore $JAVA_HOME/lib/security/cacerts -storepass changeit -alias <证书别名> -file <证书文件路径> ``` 其中 `<证书别名>` 是为证书指定的名称,`<证书文件路径>` 是下载的SSL证书文件路径[^1]。 #### 方法三:更换可信的Maven镜像源 如果当前使用的Maven镜像源存在证书问题,可以尝试更换为其他可信的镜像源。例如,将 `settings.xml` 文件中的镜像配置更改为阿里云的HTTPS镜像源: ```xml <mirror> <id>aliyun</id> <mirrorOf>*</mirrorOf> <name>Aliyun Maven</name> <url>https://maven.aliyun.com/repository/public</url> </url> ``` 确保使用的是HTTPS协议,以避免SSL证书相关问题[^2]。 #### 方法四:升级Maven版本 某些旧版本的Maven可能存在SSL兼容性问题。建议升级到最新版本的Maven,以获得更好的SSL支持和安全性改进[^4]。 #### 示例代码:通过命令行运行Maven并忽略SSL验证 ```bash mvn archetype:generate \ -Dmaven.wagon.http.ssl.insecure=true \ -Dmaven.wagon.http.ssl.allowall=true \ -Dmaven.wagon.http.ssl.ignore.validity.dates=true ``` --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值