eclipse maven将战争部署到nexus OSS访问被拒绝错误代码401,未授权 [英] eclipse maven deploy war to nexus OSS Access denied Error code 401, Unauthorized

查看:156
本文介绍了eclipse maven将战争部署到nexus OSS访问被拒绝错误代码401,未授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将已部署的war文件从Eclipse中的maven上传到nexus OSS,但出现错误消息.

I want to upload the deployed war file from maven in eclipse to nexus OSS, but I get an error message.

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xxx: Failed to deploy artifacts: Could not transfer artifact com.xxx.xxx:xxx:war:5.2.0 from/to nexus (http://xxx.xxx.xxx.xxx:8081/repository/maven-releases/): Access denied to http://xxx.xxx.xxx.xxx:8081/repository/maven-releases/com/xxx/xxx/xxx/5.2.0/xxx-5.2.0.war. Error code 401, Unauthorized -> [Help 1]

使用相同的配置( pom.xml settings.xml ),我部署了一个jar文件,它可以正常工作.

With the same configuration (pom.xml and settings.xml) I deploy a jar file and it works.

两者的区别在于文件类型和文件大小.一个是具有80mb的战争文件,另一个是只有400kb的jar文件.

The difference both of them are file type and file size. The one is a war file with 80mb and the other is a jar file with only 400kb.

有人有想法,如何解决?有没有我想念的配置?这不是1周前发生的事情.我什么都没做,只将eclipse版本从2019年更新到2020年.

Does someone have ideas, how to solve this? are there configuration, those I miss? It was not happen 1 week ago. I don't change anything, only update the eclipse version from 2019 to 2020.

谢谢

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xxx: Failed to deploy artifacts: Could not transfer artifact com.xxx.xxx:xxx:war:5.2.0 from/to nexus (http://192.168.xxx.xxx:8081/repository/maven-releases/): Access denied to http://192.168.xxx.xxx:8081/repository/maven-releases/com/xxx/xxx/xxx/5.2.0/xxx-5.2.0.war. Error code 401, Unauthorized
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not transfer artifact com.xxx.xxx:xxx:war:5.2.0 from/to nexus (http://192.168.xxx.xxx:8081/repository/maven-releases/): Access denied to http://192.168.xxx.xxx:8081/repository/maven-releases/com/xxx/xxx/xxx/5.2.0/xxx-5.2.0.war. Error code 401, Unauthorized
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    ... 20 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact com.xxx.xxx:xxx:war:5.2.0 from/to nexus (http://192.168.xxx.xxx:8081/repository/maven-releases/): Access denied to http://192.168.xxx.xxx:8081/repository/maven-releases/com/xxx/xxx/xxx/5.2.0/xxx-5.2.0.war. Error code 401, Unauthorized
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:146)
    at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:157)
    ... 22 more
Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact com.xxx.xxx:xxx:war:5.2.0 from/to nexus (http://192.168.xxx.xxx:8081/repository/maven-releases/): Access denied to http://192.168.xxx.xxx:8081/repository/maven-releases/com/xxx/xxx/xxx/5.2.0/xxx-5.2.0.war. Error code 401, Unauthorized
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:301)
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:213)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:386)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:142)
    ... 24 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact com.xxx.xxx:xxx:war:5.2.0 from/to nexus (http://192.168.xxx.xxx:8081/repository/maven-releases/): Access denied to http://192.168.xxx.xxx:8081/repository/maven-releases/com/xxx/xxx/xxx/5.2.0/xxx-5.2.0.war. Error code 401, Unauthorized
    at io.takari.aether.connector.AetherRepositoryConnector$2.wrap(AetherRepositoryConnector.java:889)
    at io.takari.aether.connector.AetherRepositoryConnector$2.wrap(AetherRepositoryConnector.java:1)
    at io.takari.aether.connector.AetherRepositoryConnector$PutTask.flush(AetherRepositoryConnector.java:732)
    at io.takari.aether.connector.AetherRepositoryConnector.put(AetherRepositoryConnector.java:373)
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:295)
    ... 27 more
Caused by: io.takari.aether.connector.AuthorizationException: Access denied to http://192.168.xxx.xxx:8081/repository/maven-releases/com/xxx/xxx/xxx/5.2.0/xxx-5.2.0.war. Error code 401, Unauthorized
    at io.takari.aether.connector.AetherRepositoryConnector.handleResponseCode(AetherRepositoryConnector.java:397)
    at io.takari.aether.connector.AetherRepositoryConnector.access$8(AetherRepositoryConnector.java:391)
    at io.takari.aether.connector.AetherRepositoryConnector$PutTask.run(AetherRepositoryConnector.java:703)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.xxx.xxx</groupId>
    <artifactId>xxxxxx</artifactId>
    <packaging>war</packaging>
    <version>1.0.0</version>
    <name>xxx xxx Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <distributionManagement>
        <repository>
            <id>nexus</id>
            <url>http://192.xxx.xxx.xxx:8081/repository/maven-releases/</url>
        </repository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>nexus</id>
            <name>Nexus OSS Internal Repository</name>
            <url>http://192.xxx.xxx.xxx:8081/repository/maven-public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Nexus OSS Internal Repository</name>
            <url>http://192.xxx.xxx.xxx:8081/repository/maven-public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <properties>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <java.version>1.8</java.version>

        <maven.test.skip>true</maven.test.skip>
    </properties>

    <dependencies>

    </dependencies>

    <build>

        <finalName>${project.artifactId}-${project.version}</finalName>
        <defaultGoal>deploy</defaultGoal>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>

    </build>

</project>

setting.xml

setting.xml

    <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">

  <localRepository>Z:/maven/repository</localRepository>

  <pluginGroups>
  </pluginGroups>
  <proxies>
  </proxies>

  <servers>
    <server>
      <id>nexus</id>
      <username>user</username>
      <password>password</password>
    </server>
  </servers>

  <mirrors>
  </mirrors>

  <profiles>
  </profiles>

</settings>

推荐答案

我遇到了同样的问题,并困惑了数周.我发现此问题是从Eclipse 202003版本开始发生的.对V201912使用相同的配置,或者仅对CMD进行部署就可以了.

I have got the same problem and have been confused for weeks. I found this problem was occurred since Eclipse version 202003. Use same configs with V201912 or just deploy with CMD is fine.

我认为这是eclipse嵌入式Maven的问题;

I think it's a problem of eclipse's embedded Maven;

  • 在V201912中为3.6.3/1.14.0.20191209-1923
  • 在V202006中为3.6.3/1.16.0.20200610-1735.

在V202006中更改为使用最近外部的Maven工件3.6.3是可以的.因此,由于我有数十个工作区,因此目前只能使用V201912.

Change to use an recently outer Maven artifacts 3.6.3 in V202006 is OK. So since I have dozens of workspaces I could only to use V201912 for now.

eclipse-202009将需要java11,并且不再支持java8,那么,我们将永远忍受这个问题吗?

The eclipse-202009 will require java11 and dosen't support java8 any more, so, we will endure the problem forever?

这篇关于eclipse maven将战争部署到nexus OSS访问被拒绝错误代码401,未授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆