2

I have specified a local repository in my settings.xml in %USERPROFILE%.m2 directory.

     <profile>
        <id>mainprofile</id>
        <repositories>
            <repository>
              <url>http://maven/maven2</url>

However when I do the maven build, it tries to download from the maven central repo

[INFO] Scanning for projects...

Downloading: http://repo1.maven.org/maven2/com/tiger/t-parent/4.0.1/t-parent-4.0.1.pom

[INFO] Unable to find resource 'com.tiger:t-parent:pom:4.0.1' in repository central (http://repo1.maven.org/maven2)

Why does this happen? Please help before I shoot myself.

Update: If I explicitly specify the option --settings=%USERPROFILE%\.m2\settings.xml in the maven command line, then it works. Why does it not use it automatically like it is supposed to?

Walking Corpse
  • 107
  • 7
  • 31
  • 49

3 Answers3

1

Use mvn -X to find out from which different locations Maven reads settings.xml. The switch activates debug logging. Just check the first lines.


Have you moved the folder location of your Windows desktop? In that case, user.home might not resolve to %USERPROFILE%\.m2. For details, have a look at my answer to Missing Maven .m2 folder.

Community
  • 1
  • 1
Martin Ackermann
  • 1,066
  • 10
  • 15
1

carefully check your pom(s) if these are free of unwanted repository entries. These might look like:

<repositories>
  <repository>
    <id>tiger</id>
    <name>tiger repository</name>
    <url>http://some.idiot.put.this.url.here/404.not.found</url>
  </repository>
</repositories>

Stuff like above bite me one. I'll never forget that.

gnat
  • 6,213
  • 108
  • 53
  • 73
  • I only have our local repository specified in the repositories section. There is no other repository entry. Also pleaes see my update in my question. – Walking Corpse Jul 28 '11 at 11:50
  • I see. Did you check environment for _M2_HOME_? by the way which version maven are you using? – gnat Jul 28 '11 at 12:23
  • Yes, M2_HOME is set to C:\apache-maven-2.2.1 and this is the maven version I'm using. – Walking Corpse Jul 28 '11 at 12:34
  • strange. Mine is almost the same _C:\dev\apache-maven-2.2.1_ and it works like a charm. Did you check C:\apache-maven-2.2.1\conf\settings.xml? is _localRepository_ entry commented there? it's commented by default – gnat Jul 28 '11 at 12:40
  • Yes it is commented out, I didn't touch that file. Let us give up, I will live, as I'm able to do the build by explicitly specifying the settings.xml file. – Walking Corpse Jul 28 '11 at 16:27
  • +1 for the url 'some.idiot.out.this.here' loved it and understand the frustration when we get hit with such issues with maven – satish marathe Aug 08 '15 at 04:35
0

Did you set a mirror?

<mirrors>
   <mirror>
     <!--This sends everything else to /public -->
     <id>nexus</id>
     <mirrorOf>*</mirrorOf>
     <url>http://maven/maven2</url>
   </mirror>
</mirrors>

From Sonatype's Nexus book, altered url.

Jacob
  • 41,721
  • 6
  • 79
  • 81