Maven私服搭建教程

一、nexus安装

1,解压安装包 安装包下载地址

2,以管理员身份打开cmd

3,进入到nexus的bin目录

(1) 安装:nexus install

(2) 启动:nexus start

(3) 停止的命令:nexus stop

4,访问:http://localhost:8081/nexus

登录:用户名/密码 admin/admin123

5,查看仓库

(1) 每个仓库的作用

① 3rd party: 无法从公共仓库获得的第三方发布版本的构件仓库

② Apache Snapshots: 用了代理ApacheMaven仓库快照版本的构件仓库

③ Central: 用来代理maven中央仓库中发布版本构件的仓库

④ Central M1 shadow: 用于提供中央仓库中M1格式的发布版本的构件镜像仓库

⑤ Codehaus Snapshots: 用来代理CodehausMaven 仓库的快照版本构件的仓库

⑥ Releases: 用来部署管理内部的发布版本构件的宿主类型仓库

⑦ Snapshots:用来部署管理内部的快照版本构件的宿主类型仓库

二、更新索引

  1. 停止服务 使用管理员身份进入bin目录,执行:nexus stop
  2. 解压压缩包 压缩包地址

   

  3.以管理员身份在此目录打开cmd,执行: java -jar indexer-cli-5.1.1.jar -u nexus-maven-repository-index.gz -d indexer(这个过程会比较慢)

   

  执行完成之后会在该目录生成一个文件夹indexer

   

  4.打开nexus 的central-ctx目录,例:D:\sonatype-work\nexus\indexer\central-ctx,清空该文件夹,将新生成的indexer中的内容考到该目录

   

  5.重新启动nexus -登陆-按照如下进行搜索-出现右侧结果说明索引更新成功

  

三、上传jar包到3rd party(上传三方jar包):

  1. 选中3rd party

  

    2.按照下图上传三方jar包    

  

四、修改 Maven 镜像配置

  1. 找到项目中使用的settings.xml,加入:  
        <profile>
<repositories>
<profile>
<repositories>
<repository>
<!--仓库id,可以配置多个仓库要保证id不重复-->
<id>public</id>
<!--仓库地址,也就是我们私服的仓库组地址-->
<url>http://192.168.11.3:8081/nexus/content/groups/public/</url>
<!--是否下载releases版本的jar-->
<releases>
<enabled>true</enabled>
</releases>
<!--是否下载snapshots版本的jar-->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</repositories>
<!--插件仓库,maven运行时的命令依赖的插件jar包,也从私服下载-->
<pluginRepositories>
<pluginRepository>
<id>public</id>
<url>http://192.168.11.3:8081/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>

  2.以及下面红框中内容:

<!-- 激活profiles -->
<activeProfiles>
<activeProfile>devlop</activeProfile>
</activeProfiles> 

五、在maven项目中使用

在项目中加入以下内容:

    <repositories>
<repository>
<id>public</id>
<name>Public Repositories</name>
<url>http://localhost:8081/nexus/content/groups/public//</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

最新文章

  1. KALI Linux problems &amp; Study Red Hat | Ubuntu
  2. 【UWP】解析GB2312、GBK编码网页乱码问题
  3. Object-c 类方法和实例方法的区别和联系
  4. 使用Maven来写j2ee项目
  5. 关于WEB Service&amp;WCF&amp;WebApi实现身份验证之WCF篇(1)
  6. Linux之curl命令详解
  7. c#开发Mongo笔记第四篇
  8. DOM笔记(四):HTML 5 DOM复杂数据类型
  9. (转载)linux环境变量
  10. CSS3随笔系列之transform(一)—— transform-origin
  11. CRT远程连接server字符输出乱码解决一例
  12. JavaSE之绘制菱形
  13. AutoFac+ASP.NetMvc,AspNet.Core
  14. NoSQL数据库
  15. SpringMVC之数据传递一
  16. pom大全
  17. 【Android】Android取消EditText自动获取焦点
  18. crontab 例子
  19. iOS11 Xcode 9 按住command 单击 恢复到从前(直接跳转到定义)
  20. leetcode Roman Integer

热门文章

  1. 使用ScrollRect制作翻页
  2. sql语言分类及区别、显示和隐示提交的指令
  3. 全文检索工具elasticsearch和kibana安装
  4. MySQL常用命令符
  5. 如何把U盘的两个盘或者多个盘合成一个
  6. Web测试控件测试点总结
  7. PLSQL官网下载地址
  8. Tomcat/conf/server.xml文件中docBase和path的说明
  9. python3练习100题——021
  10. \r、\n、\r\n的区别-转载