2015-01-20 241 views
3

我正在尝试使用maven构建moquette,作为Maven艰难的完整新手。Maven:无法解决依赖关系(找不到工件)

我使用以下命令来构建。

MVN全新安装-U

而且

MVN全新安装-U | grep的错误

结果如下:

[ERROR] Failed to execute goal on project moquette-broker: Could not resolve dependencies for project org.eclipse.moquette:moquette-broker:jar:0.7-SNAPSHOT: Could not find artifact org.mapdb:mapdb:jar:1.1.0-SNAPSHOT in Paho Releases (https://repo.eclipse.org/content/repositories/paho-releases/) -> [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 articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException 
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command 
[ERROR] mvn <goals> -rf :moquette-broker 

的完整输出:

MVN干净安装-e -X -U

可以发现here

的pom.xml样子:

<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> 
    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <netty.version>4.0.24.Final</netty.version> 
     <source.version>1.7</source.version> 
     <target.version>1.7</target.version> 
    </properties> 

    <groupId>org.eclipse.moquette</groupId> 
    <artifactId>moquette-parent</artifactId> 

    <packaging>pom</packaging> 
    <version>0.7-SNAPSHOT</version> 
    <name>Moquette MQTT parent</name> 
    <url>http://code.google.com/p/moquette-mqtt/</url> 


    <modules> 
     <module>parser_commons</module> 
     <module>netty_parser</module> 
     <module>broker</module> 
     <module>distribution</module> 
     <module>bundle</module> 
    </modules> 

    <reporting> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>cobertura-maven-plugin</artifactId> 
       <version>2.6</version> 
      </plugin> 
     </plugins> 
    </reporting> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <configuration> 
        <source>${source.version}</source> 
        <target>${target.version}</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

是什么原因造成这个问题,如何解决这一问题?

+0

您使用的是正确的存储库吗?我去了存储库列出(https://repo.eclipse.org/content/repositories/paho-releases/)和JAR不在那里 – Ascalonian 2015-01-20 19:24:09

回答

4

根据绒毛的documentation,一个简单的mvn clean install应该这样做:

库,光盘放入克隆的来源和一个git克隆后:MVN清洁套装。在分发/目标目录中,将生成具有所有依赖关系和运行脚本的代理的自包含tar。

换句话说,你做的一切都是正确的。

但是,依赖关系org.mapdb:mapdb:jar:1.1.0-SNAPSHOT缺失(截至2015年1月20日)。换句话说,安装说明是不够的。

通过引用MapDB documentation,他们每晚发布构建到存储库。如果您将其添加为存储库,它的工作(我只是验证了这一点我自己):

<repositories> 
    <repository> 
     <id>sonatype-snapshots</id> 
     <url>https://oss.sonatype.org/content/repositories/snapshots</url> 
    </repository> 
</repositories> 

您可以直接把这个定义在您的POM文件,或者在Maven安装的settings.xml文件进行配置,根据说明here

因此,对于你的POM,它看起来就像这样:

<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> 

    <repositories> 
     <repository> 
      <id>sonatype-snapshots</id> 
      <url>https://oss.sonatype.org/content/repositories/snapshots</url> 
     </repository> 
    </repositories> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <netty.version>4.0.24.Final</netty.version> 
     <source.version>1.7</source.version> 
     <target.version>1.7</target.version> 
    </properties> 

    <groupId>org.eclipse.moquette</groupId> 
    <artifactId>moquette-parent</artifactId> 

    <packaging>pom</packaging> 
    <version>0.7-SNAPSHOT</version> 
    <name>Moquette MQTT parent</name> 
    <url>http://code.google.com/p/moquette-mqtt/</url> 


    <modules> 
     <module>parser_commons</module> 
     <module>netty_parser</module> 
     <module>broker</module> 
     <module>distribution</module> 
     <module>bundle</module> 
    </modules> 

    <reporting> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>cobertura-maven-plugin</artifactId> 
       <version>2.6</version> 
      </plugin> 
     </plugins> 
    </reporting> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <configuration> 
        <source>${source.version}</source> 
        <target>${target.version}</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

为了解释这个有点多,行家检查中所配置的存储库所需的器物。在大多数情况下,工件存在于“默认”存储库中,不需要额外的存储库。

另一方面,假设您已经构建了自己的maven工件,并托管了自己的maven存储库。您将工件发布到该存储库。现在,如果其他用户想要使用它,他们将不得不做类似于上面的配置。

顺便说一句,-U强制更新,这是不需要的,除非你真的想迫使maven下载/重新下载依赖关系。

+0

我已经编辑我的pom.xml文件到http:// pastebin。 com/zxD9juY5会导致相同的错误。我知道我必须在我的pom.xml的'project'标签中包含这些存储库,所以这个文件对我来说似乎是正确的?创建一个名为'〜/ .m2/settings.xml'的空文件并将这些存储库粘贴到该文件中也会导致此错误。 – Wouter 2015-01-20 19:56:42

+0

@Wouter我实际上误解了你的问题。您需要添加另一个存储每晚构建的存储库。有问题的依赖似乎还没有进入“默认”maven仓库。看到我更新的答案。 – Magnilex 2015-01-20 20:21:37

相关问题