无法使用mvn clean deploy从同一台计算机上的工件上载到Nexus,在我的本地Windows 10计算机上也可以正常工作

问题描述 投票:0回答:1

Java 11

我有一个非常基本的Spring Boot应用程序,我想在Nexus服务器上构建和部署工件。

mvn干净部署(从我的本地Win 10机器-工作!!!]

mvn干净部署(从Nexus计算机-失败????)

mvn干净部署(来自Jenkins-失败????)

[当我从本地mvn clean deploy计算机运行Win 10命令时,所有工件都已成功部署到远程Nexus服务器上,甚至可以查看和浏览它们。

但是当我克隆项目并在安装了mvn clean deployNexusJenkins框)的同一台计算机上运行Ubuntu时,会出现Not authorized错误。

我已经从本地settings.xml机器上同时复制了settings-security.xmlWindows到安装了Ubuntu~/.m2Nexus)。

我也已禁用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
java spring-boot maven jenkins nexus
1个回答
0
投票

MVN干净部署(从Nexus计算机-失败????)]

[确定您要从复制了mvn clean deploy$HOME/.m2文件的settings.xml目录下的同一用户运行settings-security.xml吗?

而且,您是否尝试过将密码直接添加到settings.xml以排除settings-security.xml的问题(如果有)?

P.S:避免以mvn特权运行sudo命令。

© www.soinside.com 2019 - 2024. All rights reserved.