[Maven] Missing artifact (解決辦法)


在使用Eclipse的Maven插件時,經常會遇到Missing artifact的編譯錯誤,特別是在新環境中搭建相關項目時,經常出現類似此問題,今天一位同事又遇到了,經過一頓問題原因查找,始終無法解決,決定來好好研究研究此類問題,以免以后遇到此類問題。

 

以下為嘗試過的辦法:

1. 項目右鍵->Maven->Update Dependency,失敗

2. 項目右鍵->Maven->Disable Dependency, 然后再Enable Dependency,失敗

3. 將Eclipse此類項目刪除掉(不刪除磁盤上的文件),重新導入,問題依舊,失敗

4. 將相應項目從磁盤上刪除,再從SVN重新下載下來,導入,問題依舊,失敗

 

在經歷了以上各種嘗試之后,發現問題不在這些配置上,可能是某些地方沖突導致,不甘心的在網上搜索了一下,找到一篇解決辦法:http://blog.csdn.net/mydeman/article/details/6126503

分析原因說是由於其中某個jar包導致,再仔細查看我打出的日志文件之后發現,跟文章中說明的很相似,而且我第一個報錯的Jar包確實也沒有pom文件,如下圖:

image

其他正常的jar包:

image

所以問題原因就清楚了,按照前面的解決辦法需要上傳相應的pom文件至nexus上去,但是不能放到私服的Central里面,只能放到3rd party,里面,而我們的項目中引用的該文件又不能隨意改動,因為引用的項目太多了,暫時還找不到更好的解決辦法。

在這里找到貌似可以創建pom文件的辦法:

http://stackoverflow.com/questions/4906017/maven-project-build-problems

文章中這樣說:

  • Manually install each dependant jars using the maven install:install-file command in the local repository. This will automatically create the poms for the jars and thus make it available to maven in subsequent runs.

使用maven install:install-file會自動創建poms,嘗試這種辦法之后,在項目目錄下面執行此命令報錯access is denied:

C:\career\tools\develop\svn\sources\v2.0\h2o\trunk\modules\utility>mvn install:i
nstall-file -DgroupId=opensymphony -DartifactId=quartz-all -Dversion=1.6.3 -Dpac
kaging=jar -Dfile=C:/career/tools/develop/maven/repositories/oecs-repository/rep
o/opensymphony/quartz-all/1.6.3
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for
com.orientpay:op-h2o-utility:jar:2.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-comp
iler-plugin is missing. @ line 1116, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten t
he stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support buildin
g such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building op-h2o-utility 2.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ op-h2o-utilit
y ---
[INFO] Installing C:\career\tools\develop\maven\repositories\oecs-repository\rep
o\opensymphony\quartz-all\1.6.3 to C:\career\tools\maven\repositories\oecs-repos
itory\repo\opensymphony\quartz-all\1.6.3\quartz-all-1.6.3.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.399s
[INFO] Finished at: Wed Aug 06 11:36:48 CST 2014
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3
.1:install-file (default-cli) on project op-h2o-utility: Error installing artifa
ct 'opensymphony:quartz-all:jar': Failed to install artifact opensymphony:quartz
-all:jar:1.6.3: C:\career\tools\develop\maven\repositories\oecs-repository\repo\
opensymphony\quartz-all\1.6.3 (Access is denied) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
C:\career\tools\develop\svn\sources\v2.0\h2o\trunk\modules\utility>

在網上搜索之后異常”access is denied“之后,修復該問題需要將本地倉庫清空,再執行命令

根據上面的提示信息,可以在命令末尾添加-X: 在debug模式運行,而使用-e: 查看full stack錯誤信息,為了看到更加詳細的信息,加上-X之后打印如下:

[DEBUG]   (f) packaging = jar
[DEBUG]   (f) repositoryLayout = default
[DEBUG]   (f) updateReleaseInfo = false
[DEBUG]   (f) version = 1.6.3
[DEBUG] -- end configuration --
[DEBUG] Installing generated POM
[INFO] Installing C:\career\tools\develop\maven\repositories\oecs-repository\rep
o\opensymphony\quartz-all\1.6.3 to C:\career\tools\maven\repositories\oecs-repos
itory\repo\opensymphony\quartz-all\1.6.3\quartz-all-1.6.3.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.938s
[INFO] Finished at: Wed Aug 06 12:07:56 CST 2014
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3
.1:install-file (default-cli) on project op-h2o-utility: Error installing artifa
ct 'opensymphony:quartz-all:jar': Failed to install artifact opensymphony:quartz
-all:jar:1.6.3: C:\career\tools\develop\maven\repositories\oecs-repository\repo\
opensymphony\quartz-all\1.6.3 (Access is denied) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-install-plugin:2.3.1:install-file (default-cli) on
project op-h2o-utility: Error installing artifact 'opensymphony:quartz-all:jar'
: Failed to install artifact opensymphony:quartz-all:jar:1.6.3: C:\career\tools\
develop\maven\repositories\oecs-repository\repo\opensymphony\quartz-all\1.6.3 (A
ccess is denied)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:217)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)

由於不想刪除本地倉庫,只能待以后有機構再嘗試了,現在就這樣。

 

另外找到一個Quzrtz的demo樣例,http://www.mkyong.com/java/quartz-scheduler-example/,里面給出的dependency是如下的,而不是我的配置文件中的quartz-all,這可能也是為什么在maven倉庫里面下不到相關pom文件:

		<dependency>
			<groupId>opensymphony</groupId>
			<artifactId>quartz</artifactId>
			<version>1.6.3</version>
		</dependency>
但是我們的pom文件是不能修改的


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM