1

I have installed nexus repository 3.12 in a server machine and apache-maven 3.3.9 in my local computer.

I want to configure maven to access repository. I created a repository in nexus as maven_ub and edit the settings.xml file as below.

File path : C:\Program Files\apache-maven-3.3.9\conf\settings.xml

<mirrors>
   <mirror>
     <id>Nexus</id>
     <mirrorOf>central</mirrorOf>
     <name>Nexus Public Mirror</name>
     <url>http://1.2.3.4:8081/repository/maven_ub/</url>
   </mirror>
</mirrors>

But still when i build the project with dependencies it gets the dependencies through the maven central repository.

Is any one can explain how to fix this issue.Thanks in advance.

Shalika
  • 1,457
  • 2
  • 19
  • 38
  • 1
    Use "*", you want to override all repository definitions with the Nexus URL. Would also recommend running "mvn help:effective-settings" to see what is actually in effect, there could be something in your local settings.xml that is overriding the global one. – rseddon May 31 '18 at 13:31
  • thank you @rseddon. As you said the issue was local settings.xml file was override the global setting.xml file. I added the mirror configuration to .m2/settings.xml file. Then it works fine.Thank you very much. – Shalika Jun 01 '18 at 05:16
  • 1
    Put the settings.xml file into your home directory `$HOME/.m2/settings.xml` instead into the Maven installation... – khmarbaise Jun 01 '18 at 19:57

1 Answers1

1

As far as I know, you must add a custom repository to the desired pom.xml. Then, authentication credentials must be set up in your $HOME/.m2/settings.xml that way:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
    <servers>
        <server>
            <id>myRepo</id>
            <username>myUser</username>
            <password>myPass</password>
            <filePermissions>AuthenticatedRead</filePermissions>
        </server>
    </servers>
    <!-- further config -->
</settings>

You can read more in here.

joninx
  • 1,775
  • 6
  • 31
  • 59
  • 1
    Thank you @russellhoff. I tried to integrate maven with nexus with out adding any configurations to my pom.xml file. As you said i tried your suggestion too.I changed the pom.xml by adding my repository . It also works fine. Thank you very much. – Shalika Jun 01 '18 at 05:34