Maven ignores settings.xml file

2019-06-17 10:35发布

I have added proxy configuration in settigns.xml file, but it is not used by Maven, i confirmed this by making the settings.xml file invalid. I ran the maven install command to update settings and global-settings to point to the correct file, still no luck. I am using maven3.0.4.

10条回答
欢心
2楼-- · 2019-06-17 10:55

Please make sure you are using the settings.xml which you modified. for example: your using IDE's embedded maven which using different settings.xml in you operation system.

查看更多
虎瘦雄心在
3楼-- · 2019-06-17 10:57

I have also been facing the same issue. I removed the file and folder, but still maven was still picking the settings.

For me, restarting the system solved the issue.

查看更多
smile是对你的礼貌
4楼-- · 2019-06-17 10:58

Since there is no accepted answer, and I encountered that problem today and other answers proved unhlepful as the file path was correct:

The solution is to restart your computer. No, seriously. After restart maven is guaranteed to read settings.xml file again and use whatever changes you made.

查看更多
Bombasti
5楼-- · 2019-06-17 11:01

have you tried with these options: from the command line to specify the settings file?

mvn -o –Dmaven.repo.local=$HOME/.my_m2path/repository clean install --settings $HOME/.my_m2path/settings.xml  Dcheckstyle.skip=true –DskipTests

Some options that might not be necessary

  1. -o is for offline (unless you have all your repos in your m2, its suggested to skip this option)
  2. skip tests is for skipping tests while building
  3. –Dmaven.repo.local - repo path - if you are having own repo path, then use this option
  4. --settings $HOME/.my_m2path/settings.xml (remember there is space between settings and the path)
查看更多
欢心
6楼-- · 2019-06-17 11:07

You can set the path of settings file in Eclipse* as :

  1. In the menubar goto Window -> Preferences

  2. In Preferences Dialog, Goto Maven Section(On the left) and Expand it.

  3. Click on UserSettings.

  4. Add the path of settings file using Browse. The default for most users will be (C:\Users\.m2\settings.xml). It will be shown in grey but you need to actually enter the location.

  5. Click on Update Settings !

You can also enable debug logs and stack traces for debugging by clicking on the Maven Section in the Preferences dialog and Checking the box against the label "Debug Output".

  • P.S. I am currently using Eclipse(Neon) on Windows 10 x64.
查看更多
爷、活的狠高调
7楼-- · 2019-06-17 11:10

Had this issue today. I was editing the settings.xml in my USER/.m2 directory. After I changed the settings.xml in M2_HOME/conf, it worked =)

查看更多
登录 后发表回答