7.4. Setting Maven mirror using environmental variables or system properties
When running the applications you need access to the artifacts that are in the Red Hat Maven repositories. These repositories are added to Maven’s settings.xml file. Maven checks the following locations for settings.xml file:
- looks for the specified url
-
if not found looks for
${user.home}/.m2/settings.xml -
if not found looks for
${maven.home}/conf/settings.xml -
if not found looks for
${M2_HOME}/conf/settings.xml -
if no location is found, empty
org.apache.maven.settings.Settingsinstance is created.
7.4.1. About Maven mirror 复制链接链接已复制到粘贴板!
Maven uses a set of remote repositories to access the artifacts, which are currently not available in local repository. The list of repositories almost always contains Maven Central repository, but for Red Hat Fuse, it also contains Maven Red Hat repositories. In some cases where it is not possible or allowed to access different remote repositories, you can use a mechanism of Maven mirrors. A mirror replaces a particular repository URL with a different one, so all HTTP traffic when remote artifacts are being searched for can be directed to a single URL.
7.4.2. Adding Maven mirror to settings.xml 复制链接链接已复制到粘贴板!
To set the Maven mirror, add the following section to Maven’s settings.xml:
<mirror>
<id>all</id>
<mirrorOf>*</mirrorOf>
<url>http://host:port/path</url>
</mirror>
No mirror is used if the above section is not found in the settings.xml file. To specify a global mirror without providing the XML configuration, you can use either system property or environmental variables.
To set the Maven mirror using either environmental variable or system property, you can add:
-
Environmental variable called MAVEN_MIRROR_URL to
bin/setenvfile -
System property called mavenMirrorUrl to
etc/system.propertiesfile
7.4.4. Using Maven options to specify Maven mirror url 复制链接链接已复制到粘贴板!
To use an alternate Maven mirror url, other than the one specified by environmental variables or system property, use the following maven options when running the application:
-DmavenMirrorUrl=mirrorId::mirrorUrlfor example,
-DmavenMirrorUrl=my-mirror::http://mirror.net/repository-DmavenMirrorUrl=mirrorUrlfor example,
-DmavenMirrorUrl=http://mirror.net/repository. In this example, the <id> of the <mirror> is just a mirror.