当前位置: 首页 > 知识库问答 >
问题:

Eclipse maven部署战争到nexus OSS访问被拒绝错误代码401,未经授权

颜哲彦
2023-03-14

我想上传部署的战争文件从maven in eclipse到nexus OSS,但我得到一个错误消息。

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.xmlsettings.xml)我部署了一个jar文件,它可以正常工作。

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

有没有人有想法,如何解决这个问题?有没有配置,那些我想念的?这不是一周前的事。我不做任何更改,只在2019年到2020年期间更新eclipse版本。

谢谢你

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)

波姆。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>

背景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>

共有3个答案

郑茂材
2023-03-14

卸载m2e插件,包括:

  1. m2e-针对Eclipse的Maven集成

然后使用eclipse 2019-12发布网站,安装这两个插件是修复它的简单方法。

颜实
2023-03-14

okhttp中的以太连接器存在问题。https://bugs.eclipse.org/bugs/show_bug.cgi?id=562847 https://github.com/eclipse-m2e/m2e-core/issues/250

因此,2个工作组:

  • 在启动配置中使用外部Maven运行时,而不是嵌入式运行时(因此不包括乙醚)
  • 设置-Daether。连接器。基本的启动配置中的threads=1
云京
2023-03-14

我也有同样的问题,已经困惑了几个星期。我发现这个问题发生在Eclipse版本202003之后。使用与V201912相同的配置或仅使用CMD部署都可以。

我认为这是eclipse的嵌入式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。

eclipse-202009将需要java11,而dosen不再支持java8,所以,我们将永远忍受这个问题?

 类似资料:
  • 问题内容: 在某种程度上,当我尝试通过命令行访问MySQL时,已经设法解决了该错误: 我尝试使用此HowTo重置密码,但没有任何运气。 我已经卸载了mysql completley并重新安装了,但是仍然需要输入密码。我不知道为什么会这样! 有人可以帮我获得默认安装的MySQL吗? 环境 Fedora Core 10,完全根访问权限,安装了Apache和PHP 感谢您的任何帮助!! 编辑 对于所有想

  • 我最近才更新到新版本的forge,没有改变我的设置,当我去构建我的应用程序时,我得到了一个错误,说它找不到文件…

  • 这个问题已经问过好几次了,但没有一个解决办法对我有效。我以管理员身份运行DOS命令窗口,但当运行keytool命令安装证书时,我得到了上面的错误: 我在Windows10上使用JDK 1.8.0_191。为什么拒绝对管理员的访问?

  • 我正在尝试向Google AdWords API发出任何请求,该请求将返回非错误。 我使用开发者令牌创建了生产MCC帐户,此外,我还从测试帐户在google开发者控制台中创建了测试MCC帐户和OAuth2应用程序。 另外,我已经测试了不同的帐户(生产MCC,测试MCC,启用adword的用户,没有adword的用户)为auth应用程序/用户从谁的请求已 适用于任何设置/不同的客户端。我正在获取访问

  • 问题内容: 我有一个HTML表单( upload.htm ),其中包含HTML文件上传控件。 上一页中还有一个JavaScript方法,如下所示: 我在一个页面内的页面( uploadpage.htm )中 称其 为: 我尝试从 uploadpage.htm 页面执行以下所示的语句: 我收到一条错误消息,说 Access被拒绝,并且调试器在显示的第一个JavaScript函数处停止。这两个文件都位

  • 问题内容: 我在IE11和Ajax中遇到了一个特殊的错误。对于我使用下面的代码发出的几乎所有请求,一切都很好,但是当我尝试与copy + paste方法结合使用时,它会返回“访问被拒绝”错误。所以总结一下 对于我编写的所有功能,此代码在大多数浏览器中均可正常运行 在IE 11 + Windows 8.1中,它在大多数情况下均可运行,但运行特定的复制和粘贴功能时除外 有趣的是,当使用IE 11时,尽