maven 私服搭建

用户头像
kcnf
关注
发布于: 2020 年 05 月 06 日
maven私服搭建

私服环境搭建

版本选择和安装

  • jdk1.8 安装/环境配置跳过

  • [官网下载](https://www.sonatype.com/download-oss-sonatype)

  • [直接下载](http://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-3.6.0-02-unix.tar.gzz)

  • 解压 tar -zxvf nexus-3.6.0-02-unix.tar.gz

  • 分别两个文件夹

  • sonatype-work

  • nexus-3.6.0-02

  • ![avatar](https://kcnf-open.gitee.io/wiki/20200505/20200505201328524.jpg)

  • cd nexus-3.6.0-02/bin

  • ./nexus start 启动nexus

  • ![avatar](https://kcnf-open.gitee.io/wiki/20200505/20200505201439270.jpg)

  • 默认访问地址

  • http://192.168.0.103:8081/

  • 默认登录账号 admin/admin123

  • 修改账号

  • ![avatar](https://kcnf-open.gitee.io/wiki/20200505/20200505202223210.jpg)

  • 修改默认配置

  • cd /usr/local/lab/nexus-3.6.0-02/etc

  • vi nexus-default.properties

其他配置

  • Repository的type属性有:proxy,hosted,group三种

  • proxy:即你可以设置代理,设置了代理之后,在你的nexus中找不到的依赖就会去配置的代理的地址中找

  • hosted:你可以上传你自己的项目到这里面

  • group:它可以包含前面两个,是一个聚合体。一般用来给客户一个访问nexus的统一地址

  • 修改镜像代理指向阿里

  • ![avatar](https://kcnf-open.gitee.io/wiki/20200505/20200505203742591.jpg)

  • ![avatar](https://kcnf-open.gitee.io/wiki/20200505/20200505203829260.jpg)

  • ![avatar](https://kcnf-open.gitee.io/wiki/20200505/20200505204103505.jpg)

  • ![avatar](https://kcnf-open.gitee.io/wiki/20200505/20200505204121785.jpg)

  • 完整的setting和项目pom配置

  • maven setting配置

~~~

<servers>

<server>

<id>Nexus</id>

<username>admin</username>

<password>admin123</password>

</server>

</servers>

<mirrors>

<mirror>

<id>Nexus</id>

<name>Nexus Mirror</name>

<url>http://192.168.0.103:8081/nexus/repository/maven-public/</url>

<mirrorOf>*</mirrorOf>

</mirror>

</mirrors>

<profiles>

<profile>

<activation>

<activeByDefault>true</activeByDefault>

</activation>

<repositories>

<repository>

<id>Nexus</id>

<name>central</name>

<url>http://192.168.0.103:8081/nexus/repository/maven-public/</url>

<releases>

<enabled>true</enabled>

</releases>

<snapshots>

<enabled>true</enabled>

</snapshots>

</repository>

</repositories>

<pluginRepositories>

<pluginRepository>

<id>Nexus</id>

<name>central</name>

<url>http://192.168.0.103:8081/nexus/repository/maven-public/</url>

<releases>

<enabled>true</enabled>

</releases>

<snapshots>

<enabled>false</enabled>

</snapshots>

</pluginRepository>

</pluginRepositories>

</profile>

</profiles>

~~~

  • pom配置

~~~

<distributionManagement>

<snapshotRepository>

<id>Nexus</id>

<name>snapshot repository</name>

<url>http://192.168.0.103:8081/nexus/repository/maven-snapshots/</url>

</snapshotRepository>

<repository>

<id>Nexus</id>

<name>releases repository</name>

<url>http://192.168.0.103:8081/nexus/repository/maven-releases/</url>

</repository>

</distributionManagement>

~~~

  • [源码](https://gitee.com/kcnf-open/kcnf-open)

参考网址

  • https://www.cnblogs.com/sybblogs/p/9835977.html

  • https://blog.csdn.net/chenfei2341/article/details/80431700

  • https://www.cnblogs.com/qdhxhz/p/9801325.html

用户头像

kcnf

关注

还未添加个人签名 2018.03.21 加入

还未添加个人简介

评论

发布
暂无评论
maven私服搭建