簡言:
Nexus是Maven倉庫管理器,目的是搭建一個本地倉庫服務器,其實就是在公司局域網中設置一個可以供內部下載到maven 數據的服務器,這樣的好處是節省網絡資源,速度快,可以通過nexus對項目的零時版本管理,來進行模塊間的依賴開發,也可以自己發佈一些資源來共享。
1.安裝
網址:http://www.sonatype.org/nexus/下載
我的是win7系統所以下載nexus zip就ok。
在2.5版本之後的nexus支持的jdk必須在7之後,所以你要去下載最新的jdk。或這直接更新你本機的jdk。
在2.5版本之後的nexus支持的jdk必須在7之後,所以你要去下載最新的jdk。或這直接更新你本機的jdk。
win7中----》控制面板------》java32位看到這個圖標點擊,彈出窗口,在更新tab頁中更新就ok。
下載後的文件:neus-2.6.2-01-bundle.zip隨便解壓到一個地方就ok。在{base}/bin/ jswx下面有安裝和啓動nexus的腳步目錄,選擇對應你係統的目錄。我的是windows-x86-64.
這裏主要看你的jdk安裝的版本,如果jdk安裝的是64的那麼就選擇64位,如果是32就選擇32爲,應該是這樣的。
首先安裝右鍵點擊install-nexus.bat管理員運行(記住一定是管理員運行),然後右鍵點擊start-nexus.bat 。
下載驗證是否運行正常,瀏覽器中輸入:http://localhost:8081/nexus/ ,8081是nexus的默認端口號。如果沒有運行起來,那麼你需要去查看{base}/log目錄下的日誌信息了。
2.現在來說一下如何使用,來構建自己的局域網數據倉庫。
在頁面的右上角,有log in 登陸按鈕,默認的登陸用戶名密碼是 admin admin123
數據倉庫分爲三種:proxy,host,group
central 是 apache的數據倉庫,下圖是它的設置,修改dowload remote indexes 爲true
項目pom.xml中添加:
<!-- 配置部署的遠程倉庫--> <distributionManagement> <snapshotRepository> <id>nexus-snapshots</id> <name>nexus distribution snapshot repository</name> <url>http://192.168.248.129:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
修改setting.xml:
<servers> <server> <id>nexus-snapshots</id> <username>admin</username> <password>admin123</password> </server> </servers> <profiles> <profile> <id>dev</id> <repositories> <repository> <id>nexus</id> <url>http://192.168.248.129:8081/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <url>http://192.168.248.129:8081/nexus/content/groups/public</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles>