Maven's configuration settings file, PW

File Structure

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">  
    <localRepository/>
    <interactiveMode/>
    <offline/>
    <pluginGroups/>
    <servers/>
    <mirrors/>
    <proxies/>
    <profiles/>
    <activeProfiles/>
</settings>
  • localRepository: Configuring a local repository location, by default${user.home}/.m2/repository
  • interactiveMode: whether the user opens the interactive mode, the default is true
  • offline: offline mode, the default is false
  • pluginGroups: For example <pluginGroup>org.eclipse.jetty</pluginGroup>, there is a default org.apache.maven.plugins and org.codehaus.mojo.
  • servers: Configure the user name and password PW
  • mirrors: mirror acts as a blocker, it will intercept the request to the relevant maven remote repository of the request in the remote repository address, the address is redirected to mirror in the configuration.
  • proxies: the proxy configuration
  • profiles: configure the environment
  • activeProfiles: activate the default configuration environment

1- configure the user name and password

<!-- 访问私服需要的用户名和密码 -->
<servers>
    <server>
        <id>repo-releases</id>
        <username>admin</username>
        <password>admin</password>
    </server>
    <server>
        <id>repo-snapshots</id>
        <username>admin</username>
        <password>admin</password>
    </server>
</servers>

2- profile configuration

The following PW address is false.

<!-- 配置 zero-rdc-repo -->
<profile>
    <id>me-repo</id>
    <repositories>
        <!-- 配置的顺序决定了下载 jar 包的顺序 -->
        <!-- 阿里云的 release 版本 -->
        <repository>
            <id>central</id>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <!-- 私服的 release 版本 -->
        <repository>
            <id>repo-releases</id>
            <url>https://repo.rdc.aliyun.com/repository/release/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <!-- 私服的 snapshot 版本 -->
        <repository>
            <id>repo-snapshots</id>
            <url>https://repo.rdc.aliyun.com/repository/snapshot/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
    </repositories>
    <pluginRepositories>
        <!-- 阿里云插件的 release 版本 -->
        <pluginRepository>
            <id>central</id>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</profile>

repositories here if you do not configure it, there will be a default configuration Maven central repository, the same pluginRepositories If not configured, the default configuration is also a central Maven repository.

3-layer mirror

<!-- 配置拦截 repository 内的 url 进行重定向 -->
<mirrors>
    <!-- 将 central,!rdc-releases,!rdc-snapshots 的请求重定向到阿里云的公共 Maven 仓库 -->
    <!-- 其它的不重定向到阿里云 -->
    <mirror>
        <id>Nexus-aliyun</id>
        <mirrorOf>central,!rdc-releases,!rdc-snapshots</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    </mirror>
</mirrors>

Here similar to the redirection mirror, changing the url attribute repository.
Note that this is written, central,!rdc-releases,!rdc-snapshotsand not *,!rdc-releases,!rdc-snapshotsbecause we want to request the central Maven repository redirected to the cloud Ali, not all requests are redirected to the cloud Ali. Maven Central Repository is just a warehouse, open https://mvnrepository.com/repos found that we often use https://repo1.maven.org/maven2/just one of many in a warehouse, but this is relatively large and the warehouse only. If we put all requests are redirected to the warehouse, then there will depend not found.

Questions, seeking answers

Another problem is that when I configured *,!rdc-releases,!rdc-snapshots, so there is https://repo.spring.io/libs-milestone/a warehouse not download jar package, then the question is, if my configuration is central,!rdc-releases,!rdc-snapshots, and is not configured repositories is also https://repo.spring.io/libs-milestone/the repository, it is how to find it? ? ?

Guess you like

Origin www.cnblogs.com/wuqinglong/p/12057934.html