1 私服 nexus
安裝nexus
啟動服務
啟動失敗的解決方法:
登錄nexus
用戶名/密碼 admin/admin123
倉庫類型
Virtual 虛擬倉庫
Proxy 代理倉庫
Hosted 宿主倉庫 本地倉庫
Group 組
需求:
把dao放到私服上,然后service從私服上下載
需求 :將ssh_dao的這個工程打成jar包,並放入到私服上去.
1.1 上傳dao
第一步: 需要在客戶端即部署dao工程的電腦上配置 maven環境,並修改 settings.xml 文件,配置連接私服的用戶和密碼 。
此用戶名和密碼用於私服校驗,因為私服需要知道上傳都 的賬號和密碼 是否和私服中的賬號和密碼 一致。
<server> <id>releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>snapshots</id> <username>admin</username> <password>admin123</password> </server>
第二步: 配置項目pom.xml
配置私服倉庫的地址,本公司的自己的jar包會上傳到私服的宿主倉庫,根據工程的版本號決定上傳到哪個宿主倉庫,如果版本為release則上傳到私服的release倉庫,如果版本為snapshot則上傳到私服的snapshot倉庫
<distributionManagement> <repository> <id>releases</id> <url>http://localhost:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <url>http://localhost:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
注意:pom.xml這里<id> 和 settings.xml 配置 <id> 對應!
第三步:執行deploy命令發布到私服
1.2 下載dao
第一步 修改settings.xml
<profile> <!--profile的id--> <id>dev</id> <repositories> <repository> <!--倉庫id,repositories可以配置多個倉庫,保證id不重復--> <id>nexus</id> <!--倉庫地址,即nexus倉庫組的地址--> <url>http://localhost:8081/nexus/content/groups/public/</url> <!--是否下載releases構件--> <releases> <enabled>true</enabled> </releases> <!--是否下載snapshots構件--> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <!-- 插件倉庫,maven的運行依賴插件,也需要從私服下載插件 --> <pluginRepository> <!-- 插件倉庫的id不允許重復,如果重復后邊配置會覆蓋前邊 --> <id>public</id> <name>Public Repositories</name> <url>http://localhost:8081/nexus/content/groups/public/</url> </pluginRepository> </pluginRepositories> </profile> <activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles>
第二步 刪除本地倉庫中的dao
第三步 update service工程,出現以下信息說明已經成功