zoukankan      html  css  js  c++  java
  • Nexus

    nexus流程:如果构建的 Maven 项目本地仓库没有对应的依赖包,那么就会去 Nexus 私服去下载, 如果Nexus私服也没有此依赖包,就去远程中央仓库(即proxy代理仓库,默认是maven中央仓库,可设置其他的镜像)下载依赖。 Nexus 私服下载成功后再下载至本地 Maven 库供项目引用。 

    Nexus 是通过仓库组统一管理多个仓库,我们在项目中可直接通过请求仓库组来请求到 被仓库组管理的多个仓库。如:通过http://192.168.10.10:8081/nexus/content/groups/public/ 这个地址

    可以请求到下面的仓库如:http://192.168.10.10:8081/nexus/content/repositories/snapshots/等

    hosted 宿主仓库:主要用于发布内部项目构件或第三方的项目构件(如购买商业的)以及无法从公共仓库获取的构件(如 oracle 的 JDBC 驱动)。宿主仓库是我们经常用到的,本地发布就是发布到这些宿主仓库中的其中一个。

    releases:内部的模块中 release 模块的发布仓库。
    snapshots:发布内部的 SNAPSHOT 模块的仓库。
    3rd party:第三方依赖的仓库,这个数据通常是由内部人员自行下载之后发布上去。

    proxy代理仓库:代理公共的远程仓库,可以通过这个修改默认的仓库,默认的中央仓库是https://repo1.maven.org/maven2/,可以在这里改为阿里云的代理。

    下载中央仓库的索引:如下改为true

    添加代理仓库:

    然后保存,放在central上边即可。

    索引下载完成后即可看到:

    maven配置:

    maven本地库连接私有库,私有库代理连接阿里云的镜像仓库。

    settings.xml:

    <servers>
    <server>
    <!--连接仓库的id,之后pom中发布id要和此处一致-->
    <id>nexus-releases</id>
    <username>admin</username>
    <password>admin123</password>
    </server>
    <server>
    <id>nexus-snapshots</id>
    <username>admin</username>
    <password>admin123</password>
    </server>
    </servers>
    [java] view plain copy
    <code class="language-html"> <!--使用私服的配置-->  
      <profiles>  
         <profile>  
             <id>test</id>  
             <repositories>  
                 <repository>  
                     <id>nexus</id>  
                     <url>http://192.168.10.10:8081/nexus/content/groups/public/</url>  
                     <releases><enabled>true</enabled></releases>  
                     <snapshots><enabled>true</enabled></snapshots>  
                 </repository>  
             </repositories>  
             <pluginRepositories>  
                 <pluginRepository>  
                     <id>nexus</id>  
                     <url>http://192.168.10.10:8081/nexus/content/groups/public/</url>  
                     <releases><enabled>true</enabled></releases>  
                     <snapshots><enabled>true</enabled></snapshots>  
                 </pluginRepository>  
             </pluginRepositories>  
         </profile>  
      </profiles></code>  
    激活私服,激活的名字和上面私服的配置的id一致。

    <!--激活私服-->
    <activeProfiles>
    <activeProfile>test</activeProfile>
    </activeProfiles>


    pom中:这是在pom部署时连接用,id就是上面定义的server的id。且必须一致,不然连不上。这个配置一般放到顶级parent中。

    <!-- 设定团队持续集成发布包服务器 -->
    <distributionManagement>
    <repository>
    <id>nexus-releases</id>
    <url>http://${maven.local.server}/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
    <id>nexus-snapshots</id>
    <url>http://${maven.local.server}/content/repositories/snapshots</url>
    <uniqueVersion>false</uniqueVersion>
    </snapshotRepository>
    </distributionManagement>
    然后depoly即可发布到私服了。

    具体是发布到nexus-releases还是nexus-snapshots,根据要发布的包的pom文件中定义的版本version,版本中是SNAPSHOT(如:0.0.1-SNAPSHOT)就发布到snapshots中,且只能叫SNAPSHOT,其他的名字就发布到releases中了。

  • 相关阅读:
    团队项目冲刺第九天
    团队项目冲刺第八天
    团队项目冲刺第七天
    团队项目冲刺第六天
    vue-cli(vue脚手架)详细教程
    Ocelot+Consul 集群搭建实践
    docker部署net core项目
    nginx配置文件
    条码扫描器
    转载:MVVM模式解析和在WPF中的实现(六) 用依赖注入的方式配置ViewModel并注册消息
  • 原文地址:https://www.cnblogs.com/liangjiejava/p/9970093.html
Copyright © 2011-2022 走看看