Maven从私服上下载所需jar包——(十四)

 

1.修改settings.xml

将下面代码添加到settings.xml中

<profile>   
    <!--profile的id-->
    <id>dev</id>   
    <repositories>   
      <repository>  
        <!--仓库id,repositories可以配置多个仓库,保证id不重复-->
        <id>nexus</id>   
        <!--仓库地址,即nexus仓库组的地址-->
        <url>http://localhost:8081/nexus/content/groups/public/</url>   
        <!--是否下载releases构件-->
        <releases>   
          <enabled>true</enabled>   
        </releases>   
        <!--是否下载snapshots构件-->
        <snapshots>   
          <enabled>true</enabled>   
        </snapshots>   
      </repository>   
    </repositories>  
     <pluginRepositories>  
        <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
        <pluginRepository>  
            <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
            <id>public</id>  
            <name>Public Repositories</name>  
            <url>http://localhost:8081/nexus/content/groups/public/</url>  
        </pluginRepository>  
    </pluginRepositories>  
  </profile>  
<activeProfiles>

    <activeProfile>dev</activeProfile>

  </activeProfiles>

2.将dao项目从本地仓库删除

3.测试

打开maven console

更新项目出现下面信息则下载成功

4.查看从私服下载到本地仓库的项目包

5.总结:

  0.0.1是版本号,如果dao层需要做修改,修改之后需要修改版本号,可以改为0.0.2,然后通知service版本号为0.0.2,这时候service开发人员修改pom.xml将dao的版本改为0.0.2,这样就会从私服下载0.0.2版本,并将0.0.1版本从项目中一区,因为依赖版本改为0.0.2。

  这也是开发的版本号为x.x.x的原因,需要不停的往后更新,后面的版本只是在前面版本的基础上修改或者增加一些功能。

原文地址:https://www.cnblogs.com/qlqwjy/p/7287317.html