• [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 oolsdevelopsvnsourcesv2.0h2o runkmodulesutility>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 oolsdevelopmaven epositoriesoecs-repository ep
    oopensymphonyquartz-all1.6.3 to C:career oolsmaven epositoriesoecs-repos
    itory epoopensymphonyquartz-all1.6.3quartz-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 oolsdevelopmaven epositoriesoecs-repository epo
    opensymphonyquartz-all1.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 oolsdevelopsvnsourcesv2.0h2o runkmodulesutility>

    在网上搜索之后异常”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 oolsdevelopmaven epositoriesoecs-repository ep
    oopensymphonyquartz-all1.6.3 to C:career oolsmaven epositoriesoecs-repos
    itory epoopensymphonyquartz-all1.6.3quartz-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 oolsdevelopmaven epositoriesoecs-repository epo
    opensymphonyquartz-all1.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 ools
    developmaven epositoriesoecs-repository epoopensymphonyquartz-all1.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文件是不能修改的
  • 相关阅读:
    1 . CentOS 7的yum更换为国内的阿里云yum源
    0. vagrant+vbox创建centos7虚拟机
    git上传到码云和下载到本地
    spring boot udp或者tcp接收数据
    你好,博客园
    使用firdder抓取APP的包
    初见loadrunner
    sublime快捷键大全
    html中行内元素与块级元素的区别。
    html.css溢出
  • 原文地址:https://www.cnblogs.com/garinzhang/p/eclipse_maven_missing_artifact.html
Copyright © 2020-2023  润新知