linux 安装配置nexus以及maven私服应用

---------------------nexus----------------------

1、编辑nexus脚本, 配置 RUN_AS_USER 参数
vi /usr/local/src/nexus2/nexus-2.12.0-01/bin/nexus
#NEXUS_HOME=".." 改为:NEXUS_HOME="/usr/local/src/nexus2/nexus-2.12.0-01"
#RUN_AS_USER= 改为: RUN_AS_USER=root


2、修改JDK:
vi /home/nexus/nexus-2.12.0-01/bin/jsw/conf/wrapper.conf

wrapper.java.command=/usr/local/src/java/jdk1.7.0_51/bin/java

3、打开8081端口
a)/sbin/iptables -I INPUT -p tcp --dport 8081 -j ACCEPT

保存
b)/etc/rc.d/init.d/iptables save

查看端口打开
c)/etc/init.d/iptables status

4、启动 nexus
/usr/local/src/nexus2/nexus-2.12.0-01/bin/nexus start

5、设置开机启动(在/usr/local/src/nexus2/nexus-2.12.0-01/bin路径下)
cp nexus /etc/rc.d/init.d/

cd /etc/rc.d/init.d/

chkconfig --add nexus
chkconfig --list | grep nexus
chkconfig nexus on
chkconfig --list | grep nexus

6、执行如下命令启动、停止nexus服务
# service nexus start
# service nexus stop


------------------------maven-----------------------

1、解压maven 文件
tar -xvf apache-maven-3.3.9-bin.tar.gz

2、配置maven的环境变量
vim /etc/profile
export MAVEN_HOME=/usr/local/src/maven
export PATH=$PATH:$MAVEN_HOME/bin

3、使文件生效
source /etc/profile

4.测试maven是否安装成功
mvn -version

5、配置与Maven使用私服
a) linux在路径{maven_home}/conf settings.xml 文件中,
为所有仓库配置一个镜像仓库,镜像仓库的地址即私服的地址

b) windows在c盘用户.m2 settings.xml文件中,
为所有仓库配置一个镜像仓库,镜像仓库的地址即私服的地址


6、配置本地仓库(settings.xml)
<localRepository>E:\wangfg\repo</localRepository>

7、配置nexus maven针对私有项目

a) settings.xml文件
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>

b) pom文件
<!-- 自动发布构件到远程仓库-->
<distributionManagement>
<repository>
<id>nexus</id><!--这个ID需要与你的release仓库的Repository ID一致-->
<url>http://192.168.162.93:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>nexus</id><!--这个ID需要与你的snapshots仓库的Repository ID一致-->
<url>http://192.168.162.93:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<!-- 配置Maven从Nexus下载构件 -->
<repositories>
<repository>
<id>nexus</id>
<name>Team Maven Repository</name>
<url>http://192.168.162.93:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

 

8、配置通用nexus maven(settings.xml)
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</server>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<url>http://nexus-releases</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<url>http://nexus-releases</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>

 

posted @ 2017-09-27 17:49  wangfg  阅读(737)  评论(0编辑  收藏  举报