Java 11
我有一个非常基本的Spring Boot
应用程序,我想在Nexus
服务器上构建和部署工件。
mvn干净部署(从我的本地Win 10机器-工作!!!]
mvn干净部署(从Nexus计算机-失败????)
mvn干净部署(来自Jenkins-失败????)
[当我从本地mvn clean deploy
计算机运行Win 10
命令时,所有工件都已成功部署到远程Nexus
服务器上,甚至可以查看和浏览它们。
但是当我克隆项目并在安装了mvn clean deploy
和Nexus
(Jenkins
框)的同一台计算机上运行Ubuntu
时,会出现Not authorized
错误。
我已经从本地settings.xml
机器上同时复制了settings-security.xml
和Windows
到安装了Ubuntu
的~/.m2
(Nexus
)。
我也已禁用firewalls
,只是为了确保没有端口被阻塞。
我很困惑如何从远程机器而不是从同一台机器复制工件。
pom.xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<addResources>true</addResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>my-maven-snapshots</id>
<url>http://my-nexus-server/nexus/repository/maven-snapshots/</url>
</snapshotRepository>
<repository>
<id>my-maven-releases</id>
<url>http://my-nexus-server/nexus/repository/maven-releases/</url>
</repository>
</distributionManagement>
<scm>
<connection>scm:git:https://[email protected]/johndoe/todo.git</connection>
<url>https://[email protected]/johndoe/todo</url>
<developerConnection>scm:git:https://[email protected]/johndoe/todo.git</developerConnection>
<tag>HEAD</tag>
</scm>
错误(此机器上已安装Nexus):
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ todo ---
[INFO] Installing /home/admin/cloned-apps/todo/pom.xml to /home/admin/.m2/repository/com/example/todo/0.0.2-SNAPSHOT/todo-0.0.2-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ todo ---
Downloading from my-maven-snapshots: http://my-nexus-server/nexus/repository/maven-snapshots/com/example/todo/0.0.2-SNAPSHOT/maven-metadata.xml
[WARNING] Could not transfer metadata com.example:todo:0.0.2-SNAPSHOT/maven-metadata.xml from/to my-maven-snapshots (http://my-nexus-server/nexus/repository/maven-snapshots/): Not authorized , ReasonPhrase:Unauthorized.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for todo 0.0.2-SNAPSHOT:
[INFO]
[INFO] todo ............................................... FAILURE [ 4.622 s]
[INFO] todo-webapp ........................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.973 s
[INFO] Finished at: 2020-04-16T02:39:48Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project todo: Failed to retrieve remote metadata com.example:todo:0.0.2-SNAPSHOT /maven-metadata.xml: Could not transfer metadata com.example:todo:0.0.2-SNAPSHOT/maven-metadata.xml from/to my-maven-snapshots (http://my-nexus-server/nexus/repository/maven-snapshots/ ): Not authorized , ReasonPhrase:Unauthorized. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
MVN干净部署(从Nexus计算机-失败????)]
[确定您要从复制了mvn clean deploy
和$HOME/.m2
文件的settings.xml
目录下的同一用户运行settings-security.xml
吗?
而且,您是否尝试过将密码直接添加到settings.xml
以排除settings-security.xml
的问题(如果有)?
P.S:避免以mvn
特权运行sudo
命令。