0
votes

I´m trying to configure my maven to use a Nexus repository. What I´m trying to achieve should be very common: I want to have a Nexus repository working as a proxy for central dependencies and also two repositories for snapshots and releases. There´s plenty of documentation out there, but I am not able to get it running. I edited my settings.xml so that it looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0
    http://maven.apache.org/xsd/settings-1.1.0.xsd">
  <localRepository>${M2_REPO}</localRepository>
  <servers>
    <server>
      <id>nexus</id>
      <username>myuser</username>
      <password>mypass</password>
      <url>https://snapshoturl</url>
    </server>
    <server>
      <id>nexus-releases</id>
      <username>myuser</username>
      <password>mypass</password>
      <url>https://releaseurl</url>
    </server>
  </servers>
  <mirrors>
    <mirror>
      <id>nexus</id>
      <url>https://groupurl</url>
      <username>myuser</username>
      <password>mypass</password>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>myprofile</id>
      <repositories>
        <repository>
          <id>nexus</id>
          <url>https://snapshoturl</url>
          <username>myuser</username>
          <password>mypass</password>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
        <!--<repository>
                <id>nexus-releases</id>
                <url>https://releaseurl</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>false</enabled></snapshots>
              </repository>-->
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>https://groupurl</url>
          <username>myuser</username>
          <password>mypass</password>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>myprofile</activeProfile>
  </activeProfiles>
</settings>

But I always get the following error message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-
plugin:2.7:deploy (default-deploy) on project share.logging: Failed to 
retrieve remote metadata xxx:share.logging:1.0.0-SNAPSHOT/maven-
metadata.xml: Could not transfer metadata 
xxx:share.logging:1.0.0-
SNAPSHOT/maven-metadata.xml from/to p19dai-internal (https://snapshoturl): 
Not authorized , ReasonPhrase:Authorization Required. -> [Help 1]

Can anyone help me here? What am I missing?

2
This looks like an authentication error (or perhaps a large error manifesting as that error). Are you sure your credentials are correct, and is there some other way you can verify this?Tim Biegeleisen
Hi @Tim Biegeleisen, I am pretty sure this is an authentication issue and I am also pretty that my credentials are fine. What I´m not sure about is: Do I need any special roles applied to my user on Nexus?sengbatz
This looks nasty to me. The only advice I can offer would be to focus on getting one repository working at a time. This should make it easier to debug things.Tim Biegeleisen

2 Answers

1
votes

The problem is in your pom file. The ID in the "distributionManagement" section needs to match an ID in the settings.xml file's "servers". That's how the deployment credentials are looked up by Maven.

-1
votes

Are you running the mvn build via eclipse or eclipse based IDE? then go to Go to Window --> Preferences look for maven in the list and then user settings give the path to your settings.xml in both the global settings and the user settings and click apply

also set your .m2 repo path