34

I installed the maven plugin for eclipse. Then tried updating the index and got the following error:

Unable to update index for central|http://repo1.maven.org/maven2

While trying to edit the proxy settings through windows-preferences-maven-user settings, I realise there is no such file. I don't have separate maven installation and only the plugin. Please someone could help resolving the problem? Thank you very much.

Cheers A

Config: Helios Service Release 1 org.maven.ide.eclipse.feature (0.12.0.20101115-1102) "Maven Integration for Eclipse"

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
emeralddove
  • 520
  • 1
  • 5
  • 11

2 Answers2

84

The settings file is never created automatically, you must create it yourself, whether you use embedded or "real" maven.

Create it at the following location <your home folder>/.m2/settings.xml e.g. C:\Users\YourUserName\.m2\settings.xml on Windows or /home/YourUserName/.m2/settings.xml on Linux

Here's an empty skeleton you can use:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  <servers/>
  <mirrors/>
  <proxies/>
  <profiles/>
  <activeProfiles/>
</settings>

If you use Eclipse to edit it, it will give you auto-completion when editing it.

And here's the Maven settings.xml Reference page

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
  • Thank you. I am going through maven settings.xml reference page and it looks like a separate project on its own. :) Is there a quick way I can get going (trying not to loose focus on what I am doing with REST). – emeralddove Jan 07 '11 at 15:27
  • @user566930: If you just want to edit proxies, delete everything else. all elements are optional in settings.xml – Sean Patrick Floyd Jan 07 '11 at 16:39
  • Thanks. I am getting the following error: !ENTRY org.maven.ide.eclipse 4 0 2011-01-07 15:56:38.809 !MESSAGE Unable to update index for central|http://repo1.maven.org/maven2 !STACK 0 java.io.IOException: Server returned status code 403: Forbidden. – emeralddove Jan 07 '11 at 16:55
  • I think the eclipse does not cross the proxy using the info provided in settings.xml. I tried changing the credentials and same err remains. So 403 is not from repo1.maven.org/maven2 site. – emeralddove Jan 07 '11 at 18:42
  • 8
    *"The settings file is never created automatically"*. Thank you for confirming this. This got me really confused. – BalusC Jul 02 '13 at 10:54
  • 1
    does one need to reference settings.xml in pom.xml?! – Ewoks Feb 22 '16 at 15:38
  • 1
    @Ewoks no, in fact your pom.xml should never reference a settings.xml. A pom.xml is a project-specific config, shared with your team, settings.xml is your personal config (not shared) – Sean Patrick Floyd Feb 22 '16 at 16:11
1

Working on Mac I followed the answer of Sean Patrick Floyd placing a settings.xml like above in my user folder /Users/user/.m2/

But this did not help. So I opened a Terminal and did a ls -la on the folder. This was showing

-rw-r--r--@

thus staff and everone can at least read the file. So I wondered if the message isn't wrong and if the real cause is the lack of write permissions. I set the file to:

-rw-r--rw-@

This did it. The message disappeared.

LuCio
  • 5,055
  • 2
  • 18
  • 34