简体   繁体   中英

Maven uses wrong repository to lookup dependencies

In my settings.xml I declared a custom repository in a profile like this:

    <servers>
    <server>
        <id>server.id</id>
        <username><uname></username>
        <password><pw></password>
    </server>
</servers>


<profiles>
    <profile>
        <id>dev.id</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
                <id>repo.id</id>
                <url>valid working url</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
    </profile>
</profiles>

what works great for all dependencies located there, but build fails whenever I declare dependencies which are located in the central repository. For instance:

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
</dependencies>

results in:

[ERROR] Failed to execute goal on project <name>: Could not resolve dependencies for project…
…Failed to read artifact descriptor for junit:junit-dep:jar:4.9.1-SNAPSHOT: Could not transfer artifact junit:junit-dep:pom:4.9.1-SNAPSHOT from/to <server.id>…

How can I make maven load dependencies correctly?

You are trying to use a -SNAPSHOT dependency which is not available in Maven Central.

junit:junit-dep:jar:4.9.1-SNAPSHOT: Could not transfer artifact junit:junit-dep:pom:4.9.1-SNAPSHOT fr

In Maven central there are only releases available.

Furthermore the above dependency is not coming into your build by the junit:junit:4.11:jar dependency it must be comming from other sources.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM