Search code examples
javamavenintellij-ideapom.xmlnexus

Intellij Maven [Cannot resolve dependency]


I set up Nexus on my server (api.lielamar.com) and uploaded my first project called PacketManager. You can view it here: https://api.lielamar.com/#browse/browse:maven-public

For some reason, when I try to import it through pom.xml it just doesn't work. I am fairly new to Maven and extremely new to Nexus so it might be a newbie question. I tried using google and couldn't find a direct answer that worked for me.

There's my code:

    <repositories>
    <repository>
        <id>lielamar-repo</id>
        <url>https://api.lielamar.com/service/rest/repository/browse/maven-public/</url>
    </repository>
    <repository>
        <id>spigot-repo</id>
        <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.spigotmc</groupId>
        <artifactId>spigot</artifactId>
        <version>1.8.8-R0.1-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.lielamar.packetmanager</groupId>
        <artifactId>PacketManager</artifactId>
        <version>1.0</version>
    </dependency>
</dependencies>

I am also using the spigot repository which is working just fine. This is what I see on the IDE

Thank you for your time!

Edit: One of the problems were that I had my dependency calling a different repo when running mvn install or trying to compile through intellij. After adding the following code to setting.xml, I started getting a different error:

    <mirrors>
    <mirror>
        <id>lielamar-mirror</id>
        <name>lielamar mirror</name>
        <url>https://api.lielamar.com/service/rest/repository/browse/maven-public/</url>
        <mirrorOf>lielamar-api</mirrorOf>
    </mirror>
</mirrors>

The error I was getting after adding the above code was:

[ERROR] Failed to execute goal on project TestPlugin:
Could not resolve dependencies for project com.lielamar.testplugin:TestPlugin:jar:1.0:
Failure to find com.lielamar.packetmanager:PacketManager:jar:1.0 in
https://api.lielamar.com/service/rest/repository/browse/maven-public/ was cached in the local repository,
resolution will not be reattempted until the update interval of lielamar-mirror has elapsed or updates are forced -> [Help 1]`

I run the command mvn dependency:purge-local-repository from the cmd and it was built successfully, however, intellij still gives me an error: https://prnt.sc/unxppz


Solution

  • Your JAR files in the Nexus end with ..jar, so you probably made a mistake when uploading them (two dots instead of one).