经过了一天博客的阅读,手动的在Mac上搭建了基于nexus的私服 哈哈哈 以后可以当别人的Maven仓库啦~,接下来介绍一下搭建的过程。。。。。
1、官网下载nexus2.x
为什么不下载3.x呢,自我认为2.x对configuration的配置环境和maven的适配性更强,而且在接下来配置setting.xml文件时也很简单。nexus2.x 下载地址: https://help.sonatype.com/repomanager2/download
Mac将文件解压后放到/Library/Java/env/下
进入bin目录,nexus start 启动、nexus stop关闭 当然想快速启动的话可以用ln -s 在/usr/local/bin下配置连接文件 或者配置环境变量 个人认为没啥必要就没有配
2、进行nexus的配置 启动成功后登陆localhost:8081/nexus 页面如下
右上角登陆 默认账号:admin
默认密码:admin123
然后登陆后按一下顺序点击,选择configuration -》true,第6步右键单击选择repair index(选择的是proxy模式的central库 扩展性最强的是group 然后将其他库都放在group下)
结束上述操作后,点击左侧Administration 选择里面的
如果右侧出现Internet Runing等字样 那恭喜你这一步成功了
3、进行settings.xml的配置 maven/conf下的文件
由于是先配本机的私服,所以网段选择了127.0.0.1,
下面给出我的xml具体配置
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus-mirror</id>
<mirrorOf>maven-central</mirrorOf>
<url>http://127.0.0.1:8081/nexus/content/repositories/central/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexuesProfile</id>
<repositories>
<repository>
<id>maven-central</id>
<name>maven-central</name>
<url>http://127.0.0.1:8081/nexus/content/repositories/central/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexuesProfile</activeProfile>
</activeProfiles>
</settings>
4、在IDEA perfercence 中查找maven 把setting.xml引入
这样下载的package就会出现在你配置的服务器中 可以进入localhost:8081/nexus如下 查看(由于刚安装成功也就下载了一点点的文件包)