1. maven deploy报错 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8:deploy (default-cli) on project qiyi-bom: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
问题解决
-
在报错的springboot模块的pom文件中添加如下代码
<distributionManagement> <repository> <id>nexus-releases</id> <name>local Release</name> <url>仓库地址</url> </repository> <snapshotRepository> <id>snapshots</id> <url>镜像仓库地址</url> </snapshotRepository> </distributionManagement>
例:如果要发布到远程仓库
<distributionManagement> <repository> <!--稳定版本不会频繁修改的jar的存储位置--> <id>maven-release</id> <url>http://XXXX/repository/maven-releases/</url> </repository> <snapshotRepository> <!--快照版本--> <id>maven-snapshots</id> <url>http://XXXX/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>
例:如果要发布到本地仓库
<distributionManagement> <repository> <id>nexus-releases</id> <name>local Release</name> <url>file://D:/maven/qiyiiot</url> </repository> <snapshotRepository> <id>snapshots</id> <url>file://D:/maven/qiyiiot</url> </snapshotRepository> </distributionManagement>
-
修改当前maven环境的settings.xml文件添加如下代码
<servers> <!-- server | Specifies the authentication information to use when connecting to a particular server, identified by | a unique name within the system (referred to by the 'id' attribute below). | | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are | used together. |--> <server> <id>nexus-releases</id> <username>admin</username> <password>admin123</password> </server> <!-- Another sample, using keys to authenticate. <server> <id>siteServer</id> <privateKey>/path/to/private/key</privateKey> <passphrase>optional; leave empty if not used.</passphrase> </server> --> </servers>
注意这里的server的id要和前面的repository中的id对应起来,因为server就是起到一个仓库认证的作用,代码读pom.xml获取到id之后在server中找到对应id的username和password去认证