然后使用 mvn clean package deploy 命令推送到私服時遇到了 Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project fhcloud-m-oa: Failed to deploy artifacts: Could not transfer artifact org.fh:fhcloud-m-oa:jar:0.0.1-20200427.022345-1 from/to maven-snapshots (http://192.168.10.253:9002/nexus/content/repositories/snapshots): Transfer failed for http://192.168.10.253:9002/nexus/content/repositories/snapshots/org/fh/fhcloud-m-oa/0.0.1-SNAPSHOT/fhcloud-m-oa-0.0.1-20200427.022345-1.jar 401 Unauthorized -> 這個問題。
對這個問題的解決方法 在maven 插件中的 setting.xml 需要配置服務的授權信息
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
然后再項目的Pom文件需要配置自己的私服倉庫地址
<!-- 遠程nexus倉庫 -->
<distributionManagement>
<repository>
<id>release</id>
<name>Nexus Release Repository</name>
<url>http://192.168.10.253:9002/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Release Repository</name>
<url>http://192.168.10.253:9002/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
注意:setting中的 Servers中的ID 要欲 pom文件中的 repository的ID 必須一致
