- 准备工作
安装
下载maven:https://maven.apache.org/download.cgi
下载Nexus:https://www.sonatype.com/download-oss-sonatype 建议选择版本
tar zxvf nexus-2.12.0-01-bundle.tar.gz命令解压到linxu环境会出现nexus-2.12.0-01和sonatype-work两个文件,nexus-2.12.0-01中是nexus的核心文件,sonatype-work,会将下载来的开发包放置在其中 - 启动
cd /tool/nexus-2.12.0-01-bundle/nexus-2.12.0-01/bin
启动命令:./nexus start
注:启动可能会出现错误,根据错误信息进行修改,1、配置root环境变量,vi /etc/profile export RUN_AS_USER=root;2、启用修改:source /etc/profile
nexus启动成功,访问:http://IP:8081/nexus/
登录,点击右上角的log in,默认:admin/admin123可以看到左边菜单:
点击“Repositories”
点击Central,并切换到Configuration选项卡。
将Download Remote Indexes项设为True!这将打开nexus的下载远程索引的功能,便于使用nexus的搜索功能。
-
配置maven使用nexus私服,配置setting.xml文件
<!--配置私服地址映射--> <mirrors> <mirror> <id>nexus</id> <mirrorOf>*</mirrorOf> <name>MyRepository</name> <!--私服仓库地址--> <url>http://192.168.3.33:8081/nexus/content/groups/public</url> </mirror> </mirrors> <localRepository>E:\mysoft\mavenJar\m2\repository</localRepository> <!--覆盖默认的中央仓库地址--> <profiles> <profile> <id>nexus</id> <repositories> <repository> <id>central</id> <name>MyRepository</name> <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>