Nexus私服搭建

安装Nexus

安装Nexus前提是已经安装完jdk

1. 下载安装包

(由于官网似乎不太行,所以我找了一个版本不是很新的,nexus-2.12.0-01-bundle)
网盘链接: https://pan.baidu.com/s/1umMVkx6FOcVKQ54eu8LeBA 提取码: nki3

在这里插入图片描述

2. 解压到任意一个非中文目录下

在这里插入图片描述

3.进入文件夹内选择自己系统对应的版本

在这里插入图片描述
这里我是win10 64所以就进最后一个。

4. 安装服务并启动

(双击如果不行,就用管理员权限打开,有些电脑设置的权限问题。)
在这里插入图片描述

5. 查看Nexus网页服务

在做完前两步后,就可以在浏览器输入http://localhost:8081/nexus访问nexus
在这里插入图片描述
默认登入账号:密码 = admin :admin123

6. 配置文件的地址

在这里插入图片描述
可以进入配置文件修改端口号等(默认8081)
在这里插入图片描述

7.刚登入时候是什么也没的仓库,需要配置建立索引才能完成搜索功能

在这里插入图片描述
ps:这里下载可能有点慢

8. 以上弄完基本的就好了,剩下的就maven连接私服了

配置maven的settings.xml文件

添加本地仓库位置:

<localRepository>F:/Maven/repository</localRepository>

添加server

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

添加mirror

    <mirror>
		<id>nexus-releases</id>
		<url>http://localhost:8081/nexus/content/groups/public</url>
		<mirrorOf>*</mirrorOf>
	</mirror>
	<mirror>
		<id>nexus-snapshots</id>
		<url>http://localhost:8081/nexus/content/repositories/apache-snapshots/</url>
		<mirrorOf>*</mirrorOf>
	</mirror>

添加profile

 <!--JDK 配置 -->
     <profile>
      <id>jdk-1.8</id>
      <activation>
      	<activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
      </activation>
      <properties>
      	<maven.compiler.source>1.8</maven.compiler.source>
      	<maven.compiler.target>1.8</maven.compiler.target>
      	<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
      </properties>
    </profile>
    
    <!-- nexus 配置 -->
	<profile>
      <id>nexusTest</id>
      <repositories>
        <repository>
          <id>local-nexus</id>
          <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
		  <releases>
		  	<enabled>true</enabled>
		  </releases>
		  <snapshots>
		    <enabled>true</enabled>
		  </snapshots>
        </repository>
      </repositories>
    </profile>

这里nexus配置的是公共库的地址,相当于需要寻找jai包时,本地没有就去公共库中找,没有再去下载。
配置激活profile

<!-- 激活 id 为 nexusTest 的 profile -->
  <activeProfiles>
    <activeProfile>nexusTest</activeProfile>
  </activeProfiles>

到此maven settings就完成了

9.创建maven项目后在pom文件中添加私服的仓库位置

进入nexus中点击左侧的Repositoriespositories,然后点击右侧Releases,再点击右下的summary可以看见(snapshots同理)
在这里插入图片描述
然后在maven的pom文件中添加

<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>

这里的id 一定要和server的一样,不然就找不到登入的账号密码

在创建完项目,想上传私服的话就run as – maven build ,在goals中输入deploy 然后run 就好了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值