Maven实战(Maven+Nexus建立私服【Linux系统】)
準備工作
下載及配置Maven3:http://www.cnblogs.com/leefreeman/archive/2013/03/05/2944519.html
下載Nexus:http://nexus.sonatype.org/downloads/
安裝配置Nexus
Nexus提供了兩種安裝方式,一種是內嵌Jetty的bundle,只要你有JRE就能直接運行。第二種方式是WAR,你只須簡單的將其發布到web容器中即可使用。
建議下載上面這個,下載完成之后,解壓到linux的相應位置:
上圖中的 nexus-2.3.1-01和sonatype-work目錄就是解壓tar包后的兩個目錄,nexus-2.3.1-01中是nexus的核心文件,sonatype-work,會將下載來的開發包放置在其中。
cd /data/program/nexus-2.3.1-01/bin/jsw ll可以看到很多操作系統的版本目錄,選擇你的linux系統版本進去,如果不知道可以:
uname –a然后進入:
啟動nexus
./nexus startnexus啟動成功,訪問:http://192.168.6.204:8081/nexus/
點擊右上角的“log on”進行登錄,默認用戶名和密碼:admin / admin123
可以看到左邊菜單:
點擊“Repositories”
關于hosted、proxy、group的概念這里就不講了,大都介紹nexus的都有介紹,這里主要講需要做的配置?
點擊Central,并切換到Configuration選項卡。
將Download Remote Indexes項設為True!這將打開nexus的下載遠程索引的功能,便于使用nexus的搜索功能。
配置Maven使用Nexus私服
修改Maven的settings.xml 文件。
在<settings></settings>之間添加:
<profiles><profile> <id>dev</id> <repositories> <repository> <id>local-nexus</id> <url>http://192.168.6.204:8081/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile> </profiles> <!-- activeProfiles | List of profiles that are active for all builds. | --> <activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles>注意原settings.xml 文件中,已經存在profiles、activeProfiles的節點。
如果你的eclipse,安裝了m2eclipse插件,則設置:
這樣當項目需要開發包時,就會在本地倉庫查找,如果查找不到就會到私服上查找,如果還查找不找就會去中央倉庫去查找。下次等另一人需要同樣的開發包時,就會從私服中查找,效果遠比他重新從中央倉庫下載快多了。
轉載于:https://www.cnblogs.com/tonychai/p/5189164.html
總結
以上是生活随笔為你收集整理的Maven实战(Maven+Nexus建立私服【Linux系统】)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 孕妇梦到女鬼是什么意思
- 下一篇: 整理Linux查看系统日志的一些经常使用