1、nexus下载
可以去nexus官网下载,我下载的是nexus-2.13.0-01-bundle.tar
2、nexus的安装
确保已经安装maven
将下载的nexus解压至/usr/local下
tar -xvf nexus-2.13.0-01-bundle.tar
建立链接
ln -s nexus-2.13.0-01 nexus
3、将nexus设置为系统服务,并配置开机自启动
cd /etc/init.d
cp /usr/local/nexus/bin/nexus ./nexus
chmod 755 nexus
增加nexus服务
chkconfig —add nexus
chkconfig —levels 234 nexus on
4、修改
在对配置步修改的情况下,可能会遇到以下的问题:
1、If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.
2、Missing platform binary: /etc/rc.d/init.d/../bin/jsw/linux-x86-64/wrapper
其他的问题我没有遇到
修改配置
vim /etc/init.d/nexus
1
2
3
4
|
RUN_AS_USER=root
NEXUS_HOME=
"/usr/local/nexus"
PLATFORM=linux-x86-64
PLATFORM_DIR="${NEXUS_HOME}
/bin/jsw/
${PLATFORM}”
|
5、启动Nexus
service nexus start
访问http://ip:8081/nexus
默认管理员用户名/密码: admin/admin123
6、配置
7、项目使用nexus的maven配置
首先在nexus下创建用户,使其拥有Nexus Deployment Role和Nexus Full Respositroies(Full Controll)这两个权限。
userId将在下面的配置中用到
以下是maven的settings.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">
<localRepository>/Users/local/repo</localRepository>
<servers>
<server>
<id>jikefriend-releases</id>
<username>userId</username>
<password>userId</password>
</server>
<server>
<id>jikefriend-snapshots</id>
<username>userId</username>
<password>userId</password>
</server>
</servers>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>nexus</id>
<url>http://ip:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<url>http://ip:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
同时在pom.xml中加入以下内容
<repositories>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://ip:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>jikefriend-releases</id>
<name>Nexus Release Repository</name>
<url>http://ip:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>jikefriend-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url> http://ip:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>nexus</name>
<url>http://ip:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>