How to set up several settings files in the maven .m2 folder?

I am currently working on several projects each one of them has different artifactory settings. So, when switching between them I have to go to maven folder and change settings file to correspond to correct corporate repository. I’m pretty sure that it is ineffective and most likely someone already have a simple solution for this problem. May be there is some IDEA settings that I need to switch, or maven itself has some way to store them?
So, my question is – does anyone know the simple way to use several settings.xml file in the same maven home folder?

Quick google and stackoverflow search doesn’t provide any results so far.

I expect that when I open another project in Idea it will work with its own artifactory instead of using the one from previous project (since these are from different companies, obviously it is not correct to use the same one)

The answer above doesn’t quite work for me, since I’m running project via IDEA and it’s getting artifacts downloaded using single settings.xml

Leave a Reply

1 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
newest oldest most voted
Notify of

The usual way you work is to either:

  • put all repositories you need for all of your projects into your settings.xml so that it works for all projects.
  • use a Nexus/Artifactory that proxies all the repositories you need and put that as mirror into your settings.xml.

If a repository should really be only accessible for one project, you can put into the pom.xml of that project.

I don’t understand how other developers should object to putting the repositories into the pom.xml because they need the very same repositories to run the project (if not, please comment and explain).