Google Nexus私服搭建

admin
2022-02-28 / 0 评论 / 226 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年03月26日,已超过754天没有更新,若内容或图片失效,请留言反馈。

第一步骤:下载nexus私服软件nexus-2.12.0-01-bundle

第二不:安装

进入nexus解压目录进入到bin目录:

1、安装:执行nexus.bat install

2、启动:nexus.bat start

第三步:查看访问路径

进入config目录,打开nexus.properties即可看到端口号,项目命令nexus。

第四步:浏览器打开http://127.0.0.1:8081/nexus/

默认登录账号:admin/admin123

# Jetty section
application-port=8081
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
nexus-webapp-context-path=/nexus

# Nexus section
nexus-work=${bundleBasedir}/../sonatype-work/nexus
runtime=${bundleBasedir}/nexus/WEB-INF

私服使用说明:
私服介绍.png

Virtual 虚拟仓库

Proxy 代理仓库

Hosted 宿主仓库 本地仓库

Group 组

项目中如何使用:
项目中打包本地项目jar包上传到私服:

第一步:配置项目maven中setting配置文件,设置私服账号密码,才能上传到私服。
maven私服密码配置.png
添加到settings.xml中:

<server>
      <id>releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
    <server>
      <id>snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>

第二步:需要上传jia包项目的pom中配置私服地址
私服配置.png

 <distributionManagement>
      <repository>
          <id>releases</id>
    <url>http://localhost:8081/nexus/content/repositories/releases/</url>
      </repository> 
      <snapshotRepository>
          <id>snapshots</id>
    <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
      </snapshotRepository> 
  </distributionManagement>

第三步、要打包提交jar到私服的项目:
执行打包、提交到私服:
deploy

第四步:打开私服查看是否上传成功。

其他项目从私服下载jar包:
第一步:maven配置文件setting配置私服地址。
拉取远程仓库配置 maven seting配置.png
添加到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> 

激活从配置好的私服仓库拉jar包.png
激活maven配置文件中配置的私服仓库地址

  <activeProfiles>
    <activeProfile>dev</activeProfile>
  </activeProfiles>

选择要拉取jar的项目,运行maven中的update,从私服拉取jar包。

注意:
jdk安装有问题.png

安装nexus后,启动失败,可修改上面的nexus配置文件或从新安装jdk。

2

评论 (0)

取消