Are these two settings same in maven?

£可爱£侵袭症+ 提交于 2019-12-04 07:32:35

No they don't have the same effect.

The second setting add a new repository as a "complement" to central but doesn't prevent Maven to check central by itself.

The first one forces Maven to use a single repository by having it mirror all repository requests (by setting mirrorOf to *). This is the way to use a single repository.

What you're looking for is thus the first setting and need to be defined in the settings.xml.

Now, adding your corporate repository in the ~/.m2/settings.xml file of each machine can be a bit painful and what I like to do in a corporate environment is to distribute and install a "customized" version of Maven containing the mirror predefined in conf/settings.xml. This way, people just have to install the "corporate" version and they are ready to go.

No, they mean different things:

In the first example, you said that the given repository is a mirror of all repositories, including the official one.

In the second example, you simply add a new repository. In case a dependency is not found in the local repository, Maven will then look in this repository after having searched in the official repository.

Thus, to force the usage of an internal repository, you must configure the mirror in your settings.xml file.

This is explained in the official documentation of Maven.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!