Jigar Shah
Jigar Shah

Reputation: 2654

maven dependancy lookup fails even if I have specified repo

I am trying to run a project. Its not able to find a dependency. So I have added repository inside pom.xml

But its not able to lookup for the same.

from pom.xml

<repositories>
    <repository>

        <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
        </releases>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
        </snapshots>
        <id>spring</id>
        <name>Spring Framework Maven Release Repository</name>
        <url>http://oss.sonatype.org/content/groups/public</url>
        <layout>default</layout>
    </repository>

</repositories>

81749 [WARNING] Unable to create Maven project for com.gemstone.gemfire:gemfire:pom:8.1.0 from repository. org.apache.maven.project.ProjectBuildingException: Error resolving project artifact: Failure to find com.gemstone.gemfire:gemfire:pom:8.1.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced for project com.gemstone.gemfire:gemfire:pom:8.1.0

when i applied -X i see following

103850 [DEBUG] === PROJECT BUILD PLAN ================================================
103850 [DEBUG] Project:       xxxxx:xxxxxx:0.0.1-SNAPSHOT
103850 [DEBUG] Dependencies (collect): [compile+runtime]
103850 [DEBUG] Dependencies (resolve): [compile, compile+runtime, runtime, test]
103850 [DEBUG] Repositories (dependencies): [central (https://repo.maven.apache.org/maven2, default, releases)]
103850 [DEBUG] Repositories (plugins)     : [central (https://repo.maven.apache.org/maven2, default, releases)]

What am I missing here ? I have parent pom.xml with repository mention

parent is not included in child

Upvotes: 0

Views: 1457

Answers (1)

viniciusartur
viniciusartur

Reputation: 161

Given this 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>test</groupId>
    <artifactId>test</artifactId>
    <version>0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>com.gemstone.gemfire</groupId>
            <artifactId>gemfire</artifactId>
            <version>8.1.0</version>
        </dependency>
    </dependencies>
</project>

When I tried to run:

$mvn clean compile

The result was:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building test 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/com/gemstone/gemfire/gemfire/8.1.0/gemfire-8.1.0.pom
[WARNING] The POM for com.gemstone.gemfire:gemfire:jar:8.1.0 is missing, no dependency information available
Downloading: https://repo.maven.apache.org/maven2/com/gemstone/gemfire/gemfire/8.1.0/gemfire-8.1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.642 s
[INFO] Finished at: 2017-04-02T13:31:34+01:00
[INFO] Final Memory: 11M/131M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project test: Could not resolve dependencies for project test:test:jar:0.1-SNAPSHOT: Could not find artifact com.gemstone.gemfire:gemfire:jar:8.1.0 in central (https://repo.maven.apache.org/maven2) -> [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

So I researched for the dependency and repository in mvnrepository.com and I found the repositories that contains this dependency are Spring Plugins and Spring Libs:

enter image description here

Then I just added the Spring Plugins repository in my pom and it worked!

The final POM is:

<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>test</groupId>
    <artifactId>test</artifactId>
    <version>0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>com.gemstone.gemfire</groupId>
            <artifactId>gemfire</artifactId>
            <version>8.1.0</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>spring</id>
            <url>http://repo.spring.io/plugins-release</url>
        </repository>
    </repositories>
</project>

Upvotes: 1

Related Questions