下载依赖项时maven出错

时间:2011-01-31 06:26:11

标签: maven-2 maven-3

我的project1和project2在maven构建中运行良好。最近我使用这个tutorial从maven2升级到maven3(我在maven2上检查了它,但它也没有用)。对于拥有私人(自托管)Nexus回购的project2,一切正常并且工作正常。

但是,现在我在为project1下载依赖项时遇到错误(使用公共maven repo)。

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

    <groupId>com.dds.server.DDSStartup</groupId>
    <artifactId>storage</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>storage</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>r07</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>
        <dependency>
            <groupId>com.sleepycat</groupId>
            <artifactId>je</artifactId>
            <version>3.3.75</version>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>jgroups</groupId>
            <artifactId>jgroups-all</artifactId>
            <version>2.4.1</version>
        </dependency>
    </dependencies>


    <repositories>
        <repository>
            <id>oracleReleases</id>
            <name>Oracle Released Java Packages</name>
            <url>http://download.oracle.com/maven</url>
            <layout>default</layout>
        </repository>
    </repositories>
</project>

我在哪里出错,这是我做错时得到的错误:mvn clean package

[ERROR] Failed to execute goal on project storage: Could not resolve dependencies for project com.dds.server.DDSStartup:DynamicDistributedStorage:jar:1.0-SNAPSHOT: Failed to collect dependencies for [junit:junit:jar:3.8.1 (test), com.google.guava:guava:jar:r07 (compile), log4j:log4j:jar:1.2.16 (compile), com.sleepycat:je:jar:3.3.75 (compile), com.google.protobuf:protobuf-java:jar:2.3.0 (compile), jgroups:jgroups-all:jar:2.4.1 (compile)]: Failed to read artifact descriptor for log4j:log4j:jar:1.2.6: Could not transfer artifact log4j:log4j:pom:1.2.6 from/to oracleReleases (http://download.oracle.com/maven): /Users/username/.m2/repository/log4j/log4j/1.2.6/log4j-1.2.6.pom.ahc65d8d087349b4a46 (No such file or directory) -> [Help 1]

更新:

我删除了所有内容(工作区),再次导入项目,它就像一个魅力。没有什么可以击败那个解决方案;)

4 个答案:

答案 0 :(得分:5)

这也不应该与maven2一起使用。

从错误消息中,看起来maven正在尝试从您的pom中指定的存储库下载依赖项 - oracleReleases (http://download.oracle.com/maven)而不是公众maven repo。这似乎是一个无效的存储库URL。

也许您应该尝试删除该部分并重试。

答案 1 :(得分:1)

这由another stackoverflow question涵盖,归结为Oracle回购不允许目录列表。

答案 2 :(得分:1)

我将依赖项版本外部化为属性。像:

<properties>
    [...]
    <hibernate-core.version>4.1.3.Final</hibernate-core.version>
    [...]
</properties>

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>${hibernate-core.version}</version>
</dependency>

我关闭了项目,将版本声明更改为显式为

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.1.3.Final</version>
</dependency>

有效!

答案 3 :(得分:0)

orcacleReleases中的URL似乎有误,它确实指向404,也许oracle确实移动了它?