Nexus私服搭建

安装Nexus

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

1. 下载安装包

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

在这里插入图片描述

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

Nexus私服搭建_第1张图片

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

Nexus私服搭建_第2张图片
这里我是win10 64所以就进最后一个。

4. 安装服务并启动

(双击如果不行,就用管理员权限打开,有些电脑设置的权限问题。)
Nexus私服搭建_第3张图片

5. 查看Nexus网页服务

在做完前两步后,就可以在浏览器输入http://localhost:8081/nexus访问nexus
Nexus私服搭建_第4张图片
默认登入账号:密码 = admin :admin123

6. 配置文件的地址

Nexus私服搭建_第5张图片
可以进入配置文件修改端口号等(默认8081)
Nexus私服搭建_第6张图片

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

Nexus私服搭建_第7张图片
ps:这里下载可能有点慢

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

配置maven的settings.xml文件

添加本地仓库位置:

<localRepository>F:/Maven/repositorylocalRepository>

添加server

<server>
    <id>releasesid>
    <username>adminusername>
    <password>admin123password>
server>
<server>
    <id>snapshotsid>
    <username>adminusername>
    <password>admin123password>
server>

添加mirror

    <mirror>
		<id>nexus-releasesid>
		<url>http://localhost:8081/nexus/content/groups/publicurl>
		<mirrorOf>*mirrorOf>
	mirror>
	<mirror>
		<id>nexus-snapshotsid>
		<url>http://localhost:8081/nexus/content/repositories/apache-snapshots/url>
		<mirrorOf>*mirrorOf>
	mirror>

添加profile

 
     <profile>
      <id>jdk-1.8id>
      <activation>
      	<activeByDefault>trueactiveByDefault>
        <jdk>1.8jdk>
      activation>
      <properties>
      	<maven.compiler.source>1.8maven.compiler.source>
      	<maven.compiler.target>1.8maven.compiler.target>
      	<maven.compiler.compilerVersion>1.8maven.compiler.compilerVersion>
      properties>
    profile>
    
    
	<profile>
      <id>nexusTestid>
      <repositories>
        <repository>
          <id>local-nexusid>
          <url>http://127.0.0.1:8081/nexus/content/groups/public/url>
		  <releases>
		  	<enabled>trueenabled>
		  releases>
		  <snapshots>
		    <enabled>trueenabled>
		  snapshots>
        repository>
      repositories>
    profile>

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


  <activeProfiles>
    <activeProfile>nexusTestactiveProfile>
  activeProfiles>

到此maven settings就完成了

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

进入nexus中点击左侧的Repositoriespositories,然后点击右侧Releases,再点击右下的summary可以看见(snapshots同理)
Nexus私服搭建_第8张图片
然后在maven的pom文件中添加

<distributionManagement>
  <repository>
    <id>releasesid>
    <url>http://localhost:8081/nexus/content/repositories/releasesurl>
  repository>
   <snapshotRepository>
    <id>snapshotsid>
    <url>http://localhost:8081/nexus/content/repositories/snapshotsurl>
  snapshotRepository>
distributionManagement>

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

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

你可能感兴趣的:(maven)