maven2的本地配置了解

maven2的本地配置了解

其实需求很简单,我本机安装了一个私服nexus,有时也用artifactory,同时公司也有一个私服nexus。
也就是说我平时能用的私服有:
本机
http://localhost:8081/nexus
公司1
http://10.206.19.59:81/nexus
公司2
http://10.206.19.252:8081/artifactory

各个服务有时并不一定都保持开机的,所以我想我的maven2是一个一个去试,连得上哪个用哪个。最近修改了本地的settings.xml配置后,基本实现了这个功能,使用了一段时间后发现没有什么问题,现在将settings.xml配置文件记录一下:
<settings xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                               http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
  
   <profile>
      <id>nexus_local</id>
      <repositories>
        <repository>
            <id>nexus_local</id>
            <name>local private nexus</name>
            <url>http://localhost:8081/nexus/content/groups/public</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>false</enabled></snapshots>
        </repository>
        <repository>
            <id>nexus_local</id>
            <name>local private nexus</name>
            <url>http://localhost:8081/nexus/content/groups/public-snapshots</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
        <repository>
            <id>nexus_company</id>
            <name>local private nexus</name>
            <url>http://10.206.19.59:81/nexus/content/groups/public</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>false</enabled></snapshots>
        </repository>
        <repository>
            <id>nexus_company</id>
            <name>local private nexus</name>
            <url>http://10.206.19.59:81/nexus/content/groups/public-snapshots</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
            <id>nexus_local</id>
            <name>local private nexus</name>
            <url>http://localhost:8081/nexus/content/groups/public</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>false</enabled></snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>nexus_local</id>
            <name>local private nexus</name>
            <url>http://localhost:8081/nexus/content/groups/public-snapshots</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>nexus_company</id>
            <name>local private nexus</name>
            <url>http://10.206.19.59:81/nexus/content/groups/public</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>false</enabled></snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>nexus_company</id>
            <name>local private nexus</name>
            <url>http://10.206.19.59:81/nexus/content/groups/public-snapshots</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
       </pluginRepositories>
    </profile>
</profiles>
<activeProfiles>
   <activeProfile>nexus_local</activeProfile>
</activeProfiles>
</settings>

我的示例中只给出了nexus的两个服务的配置,其实按照这个思路,再多加几个artifactory或者nexus也无妨。

你可能感兴趣的:(xml)