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条回答
Juvenile、少年°
2楼-- · 2019-06-17 11:16

It's almost to stupid to tell, but it might save some time for somebody else: If you're using a new computer, make sure file extensions are displayed. Otherwise your "settings.xml" file probably is a "settings.xml.txt" file in fact...

查看更多
家丑人穷心不美
3楼-- · 2019-06-17 11:17

Try running Maven with the -X option. It should print as part of the debug output which settings file is being used.

Since you already tried it with an invalid file, I bet that something is wrong with the location of your file.

查看更多
叼着烟拽天下
4楼-- · 2019-06-17 11:18

Make sure it is in the right directory (HOME/.m2/settings.xml)

You can find the relevant paths and a proxy example here: Maven proxy settings not working

And of course the reference is always useful: https://maven.apache.org/settings.html

查看更多
Animai°情兽
5楼-- · 2019-06-17 11:20

For those using Linux

In the Ubuntu package repository (and probably other disto's too), there are two maven packages: maven and maven2. For some reason, I had maven2 installed, which seems to ignore settings.xml in ~/.m2.

As a solution, I removed it using

sudo apt-get purge maven2

and installed the other one with

sudo apt-get install maven

What's going on?

I couldn't find a reliable source, but apparently, maven2 is an older version (2.x), as the latest maven has version 3.x and is served with maven.

查看更多
登录 后发表回答