1.下载并且解压缩
2.添加NEXUS_HOME和Path
3.nexus intall将nexus安装到windows-x86-32服务中,双击install-nexus.bat
4.nexus start & stop
5.在nexus服务启动后,可以输入http://localhost:8081/nexus,就能看到Nexus的界面
6.登录Nexus,admin/admin123
7.更新私有仓库的索引
先选中Central,切换到Configuration页签,将Download Remote Indexes设置为true,save;
当然,也可以更换Remote Storage Location,默认为http://repo1.maven.org/maven2/
常用的Maven仓库有:
共有的仓库 http://repo1.maven.org/maven2/ http://repository.jboss.com/maven2/ http://repository.sonatype.org/content/groups/public/ http://mirrors.ibiblio.org/pub/mirrors/maven2/org/acegisecurity/ http://maven.glassfish.org/content/groups/glassfish/ https://nexus.sourcesense.com/nexus/content/repositories/public/ 私有的仓库 http://repository.codehaus.org/ http://snapshots.repository.codehaus.org/ http://people.apache.org/repo/m2-snapshot-repository http://people.apache.org/repo/m2-incubating-repository/
之后分别对Apache Snapshots、Codehaus Snapshots进行同样的操作。
save之后,可以查看Scheduled Tasks正在下载索引。
右击Central,Update Index,可以查看Scheduled Tasks正在更新索引(这个过程会很漫长)。
当任务消失的时候,就表明索引更新完成了,可以使用本地Nexus搜索构件。
8.配置Maven从Nexus下载构件
在${用户}\.m2目录下的settings.xml中配置Nexus仓库,并配置镜像让Maven只使用私服
<?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"> ... <mirrors> <mirror> <id>nexus</id> <mirrorOf>*</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://localhost:8081/nexus/content/groups/public</url> </mirror> </mirrors> <profiles> <profile> <id>nexus</id> <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> <activeProfile>nexus</activeProfile> </activeProfiles> ... </settings>