3,Maven 和nexus私服的使用
阿新 • • 發佈:2020-10-20
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1.倉庫型別 proxy:代理倉庫,用於代理遠端倉庫 group:倉庫組,通常包含了多個代理倉庫和宿主倉庫,在專案中只要引入倉庫組就可以下載到代理倉庫和宿主倉庫中的包 hosted:宿主倉庫,內部專案、付費jar releases 釋出內部release版本的倉庫 snapshots 釋出內部snapshots版本的倉庫 third 自建第三方jar 2.配置代理 選擇阿里雲http://maven.aliyun.com/nexus/content/groups/public/ 3.本地maven配置 修改maven目錄下的conf/setting.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/> <proxies/> <servers> <server> <id>xdclass-releases</id> <username>admin</username> //設定nexus 使用者 <password>admin123</password> </server> <server> <id>xdclass-snapshots</id> //設定nexus登陸戶和密碼 <username>admin</username> <password>admin123</password> </server> </servers> <mirrors/> <profiles> <profile> <id>xdclass</id> <activation> <activeByDefault>false</activeByDefault> </activation> <!-- 私有庫地址--> <repositories> <repository> <id>xdclass</id> <url>http://192.168.56.101:8081/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <!--外掛庫地址--> <pluginRepositories> <pluginRepository> <id>xdclass</id> <url>http://192.168.56.101:8081/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>xdclass</activeProfile> </activeProfiles> </settings> 10.修改編輯器中maven的配置,將配置指向setting.xml 11.修改pom <!--pom.xml 遠端倉庫的配置 id要跟本地maven的setting.xml相同 --> <distributionManagement> <repository> <id>xdclass-releases</id> <name>Ruizhi Release Repository</name> <url>http://192.168.56.101:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>xdclass-snapshots</id> <name>Ruizhi Snapshot Repository</name> <url>http://192.168.56.101:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement> 12.測試是否nexus搭建成功 pom新增本地沒有的依賴,看nexus會不會代理 mvn deploy 看是否成功推送至nexus