Normally, I have the following mirror configured in my Maven settings.xml
<mirror>
<id>internal-repository</id>
<url>http://build.idaho.local/wtp_repository</url>
<mirrorOf>*</mirrorOf>
</mirror>
My understanding is that this mirror prevents Maven from downloading dependencies from the internet, i.e. it will only look for them in this internal repository.
However, whenever I want to add a dependency that isn't in this internal repository, I have to comment out the text above and add the following to the project's pom.xml
<repository>
<id>internal-repository</id>
<url>http://build.idaho.local/wtp_repository</url>
</repository>
When I make these changes Maven will check for dependencies in the local repo, and if not found, download them from the internet to the local repo. Once I have the dependencies I need, I then change my configuration back.
Is there a way to get the behaviour I want - always check the internal repo, then the public (Internet) repos - without having to add the <repository>
to every project's pom.xml
?
Ideally I would like to specify this repository once in settings.xml
, but it seems that you can only configure mirrors there.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…