參考鏈接:http://www.reibang.com/p/5778a447bece
1.安裝JDK
#yum install java
#jave -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)
2.安裝maven
#yum install maven
#mvn -version
Apache Maven 3.0.5 (Red Hat 3.0.5-17)
Maven home: /usr/share/maven
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-2.b11.el7_3.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-327.22.2.el7.x86_64", arch: "amd64", family: "unix"
3.安裝nexus:我是安裝在掛載盤符 /usr/local上
------切換到下載目錄
#cd /usr/local
------下載壓縮包
#wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.12.0-01-bundle.tar.gz
------解壓
#tar -zvxf nexus-2.12.0-01-bundle.tar.gz
------重命名nexus文件夾
# mv nexus-2.12.0-01 nexus
4.安裝nexus到系統(tǒng)服務
------復制腳本到/etc/init.d
#sudo cp nexus/bin/nexus /etc/init.d/nexus
------編輯剛剛復制過去的腳本:我用root用戶啟動,但官方不推薦
#vi /etc/init.d/nexus
------修改:NEXUS_HOME="/mnt/nexus"惫周;RUN_AS_USER=root
------添加系統(tǒng)服務
#chkconfig --add nexus
#chkconfig --levels 345 nexus on
------啟動nexus
#service nexus start
5.修改nexus默認用戶名密碼
- 瀏覽器打開 域名:8081/nexus
- 右上角login:默認用戶名密碼:admin admin123
- 修改管理密碼尘惧,左邊導航欄:security>users>在admin用戶上右鍵>set password
6.倉庫配置說明:
-
group,分組
默認會有一個public分組递递,包含所有的默認倉庫喷橙,點選可在下方配置:
configuration面板,可以配置組包含的倉庫登舞,左邊為當前組包含的倉庫
borwse index面板贰逾,可以查看當前組包含的庫(proxy代理倉庫,要配置才能在這顯示)
-
hosted逊躁,本地倉庫
用于管理自己的jar包似踱,或者代理倉庫中找不到的包
上傳包:點擊要上傳的倉庫
-
proxy,代理倉庫
第三方倉庫稽煤,本地倉庫中不存在的包核芽,到代理倉庫中下載
例:添加阿里的maven倉庫
點擊菜單 add>proxy repository
- virtual,虛擬倉庫
用來兼容maven1
包搜索使用
- 本地maven倉庫配置酵熙,修改本地maven配置文件倉庫地址轧简,使用public組
配置文件位置,可以通過myeclipse>preferences>MyEclipse>MavenMyEclipse>User Setting>open file直接編輯
<mirrors>
<mirror>
<id>central</id>
<mirrorOf>*</mirrorOf>
<name>central-mirror</name>
<url>http://域名或IP:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
pom.xml 樣例
<repositories>
<repository>
<id>nexus</id>
<name>my nexus</name>
<url>http://192.168.2.92:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>my nexus</name>
<url>http://192.168.2.92:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
settings.xml 樣例
<localRepository>D:\company_mvn\Repository</localRepository>
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus-releases</id>
<url>http://192.168.2.92: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-snapshots</id>
<url>http://192.168.2.92: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>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>