一.下载和安装Nexus
1.下载Nexus
下载地址:https://www.sonatype.com/download-oss-sonatype,
进入页面,选择相应的版本(以windows为例),点击下载。
2.安装和启动Nexus
1) 配置JDK/JRE
(注意:需要JDK 8的运行环境)
Nexus自带了一个JRE,但可能无法直接使用,需要使用运行以下命令:
使用jre/bin 下的 unpack200 工具解包rt.jar.pack
unpack200 rt.jar.pack rt.jar
如有需要,可解包其它 .jar.pack 文件
2)启动Nexus
命令行启动
- 在打开命令窗口,进入
bin目录,使用命令nexus.exe /run
安装为Windows服务
在打开命令窗口,进入
bin目录,使用命令nexus.exe /install安装名为
nexus的服务打开浏览器输入:http://localhost:8081 ,这时会打开Nexus的初始欢迎界面,如下图所示
点击右上角Sign in ,进入管理员模式。(用户名:admin 密码:admin123)
二.配置Maven
1.配置 setting.xml
找到Maven 的setting.xml文件(例如:E:\maven\apache-maven-3.5.0\conf)
打开setting.xml文件,把如下代码放到相应位置。
<settings> <mirrors> <mirror> <!--This sends everything else to /public --> <id>nexus</id> <mirrorOf>*</mirrorOf> <url>http://localhost:8081/repository/maven-public/</url> </mirror> </mirrors> <profiles> <profile> <id>nexus</id> <!--Enable snapshots for the built in central repo to direct --> <!--all requests to nexus via the mirror --> <repositories> <repository> <id>central</id> <url>http://central</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://central</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <!--make the profile active all the time --> <activeProfile>nexus</activeProfile> </activeProfiles> </settings>