首页 > 代码库 > 搭建maven私仓

搭建maven私仓

公司使用国外maven源很慢,打算使用本地仓库解决依赖问题,这里搭建很简单,直接把全部命令贴上来了,一步步执行即可

maven仓库使用nexus来进行搭建,依赖jdk对应版本,步骤如下

yum -y install java-1.7.0-openjdk*

tar xzvf apache-maven-3.3.9-bin.tar.gz -C /mnt/sdb/

echo ‘export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.131.x86_64‘>>/etc/profile

echo ‘export MAVEN_HOME=/mnt/sdb/apache-maven-3.3.9‘>>/etc/profile

echo ‘export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin‘>>/etc/profile

echo ‘export CLASSPATH=.:$JAVA_HOME/lib.dt.jar:$JAVA_HOME/lib/tools.jar‘>>/etc/profile

. /etc/profile

tar xf nexus-2.14.3-02-bundle.tar.gz -C /mnt/sdb/

sed -i ‘/#RUN_AS_USER=/s/#RUN_AS_USER=/RUN_AS_USER=root/g‘ /mnt/sdb/nexus-2.14.3-02/bin/nexus

chmod +x /mnt/sdb/nexus-2.14.3-02/bin/nexus

ln -s /mnt/sdb/nexus-2.14.3-02/bin/nexus /etc/init.d/nexus

http://10.47.89.159:8081/nexus/

admin

admin123

vim /etc/init.d/nexus添加

# chkconfig: 2345 27 87

# description: Saves and restores system entropy pool for \

# higher quality random number generation.

chkconfig nexus on

登陆管理员修改密码即可

另外可以配置nginx代理

#本地私有maven仓库,使用nexus管理

location  ^~  /nexus/ {

proxy_set_header Host $http_host;

proxy_set_header X-Forward-For $remote_addr;

proxy_pass http://10.47.89.159:8081/nexus/;

}


搭建maven私仓