經過了一天博客的閱讀,手動的在Mac上搭建了基於nexus的私服 哈哈哈 以後可以當別人的Maven倉庫啦~,接下來介紹一下搭建的過程。。。。。
1、官網下載nexus2.x
爲什麼不下載3.x呢,自我認爲2.x對configuration的配置環境和maven的適配性更強,而且在接下來配置setting.xml文件時也很簡單。nexus2.x 下載地址: https://help.sonatype.com/repomanager2/download
Mac將文件解壓後放到/Library/Java/env/下
進入bin目錄,nexus start 啓動、nexus stop關閉 當然想快速啓動的話可以用ln -s 在/usr/local/bin下配置連接文件 或者配置環境變量 個人認爲沒啥必要就沒有配
2、進行nexus的配置 啓動成功後登陸localhost:8081/nexus 頁面如下
右上角登陸 默認賬號:admin
默認密碼:admin123
然後登陸後按一下順序點擊,選擇configuration -》true,第6步右鍵單擊選擇repair index(選擇的是proxy模式的central庫 擴展性最強的是group 然後將其他庫都放在group下)
結束上述操作後,點擊左側Administration 選擇裏面的
如果右側出現Internet Runing等字樣 那恭喜你這一步成功了
3、進行settings.xml的配置 maven/conf下的文件
由於是先配本機的私服,所以網段選擇了127.0.0.1,
下面給出我的xml具體配置
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus-mirror</id>
<mirrorOf>maven-central</mirrorOf>
<url>http://127.0.0.1:8081/nexus/content/repositories/central/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexuesProfile</id>
<repositories>
<repository>
<id>maven-central</id>
<name>maven-central</name>
<url>http://127.0.0.1:8081/nexus/content/repositories/central/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexuesProfile</activeProfile>
</activeProfiles>
</settings>
4、在IDEA perfercence 中查找maven 把setting.xml引入
這樣下載的package就會出現在你配置的服務器中 可以進入localhost:8081/nexus如下 查看(由於剛安裝成功也就下載了一點點的文件包)