Why is maven looking for artifact in the wrong repo?

You need to check your maven settings.xml (Look into Maven folder: M2_HOME/conf).
The default repositories are defined there itself, and Maven central repository is taking precedence.

Define your repository in Maven's settings.xml like this:

<profiles>
<profile>
  ...
  <repositories>
    <repository>
      <id>Java Net</id>
      <name>Java Net</name>
      <releases>
        <enabled>false</enabled>
        <updatePolicy>always</updatePolicy>
        <checksumPolicy>warn</checksumPolicy>
      </releases>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
        <checksumPolicy>fail</checksumPolicy>
      </snapshots>
      <url>http://download.java.net/maven/2</url>
      <layout>default</layout>
    </repository>
  </repositories>
  <pluginRepositories>
    ...
  </pluginRepositories>
  ...
</profile>

You can maybe overwrite the default Maven central repository location with yours if you don't want to do much configuration.

Cheers!


The repository that you have defined is used for dependencies, but not for plugins. Hence the error.

To address this, you need to define pluginRepositories:

<project>
    <!-- ... -->

    <pluginRepositories>
        <pluginRepository>
            <id>{repo.id}</id>
            <url>{repo.url}</url>
        </pluginRepository>
    </pluginRepositories>
</project>

As to where you should specify - in pom.xml or settings.xml, read this SO post.


In my case, the real root issue was that the repo required authentication. However for some reason maven decided that it would be much better to not tell me that, and to instead use the first repo in the <repositories> list, and throw the Could not find artifact error for that repo.

After moving the repo that contained the package so it was the first one in the <repositories> list, it started showing me a "permission denied" message. Once maven was setup for authentication with the repo in question, the issue went away.