【问题标题】:JCenter - Return code is: 401, ReasonPhrase: UnauthorizedJCenter - 返回码是:401,ReasonPhrase:未经授权
【发布时间】:2016-01-26 01:50:00
【问题描述】:

当使用 $mvn deploy 将链接的工件部署到 JCenter 时,我收到此错误 Return code is: 401, ReasonPhrase: Unauthorized.

这是什么原因造成的,如何解决?

【问题讨论】:

标签: java maven bintray jcenter


【解决方案1】:

解决方案是在工件的 pom.xml 中有这个

<distributionManagement>
    <snapshotRepository>
        <id>bintray-yourusername-maven-yourpackagename</id> <!-- same id with the server in settings.xml -->
        <name>oss-jfrog-artifactory-snapshots</name>
        <url>http://oss.jfrog.org/artifactory/oss-snapshot-local</url>
    </snapshotRepository>
</distributionManagement>

在 settings.xml 中有这个

<?xml version="1.0" encoding="UTF-8" ?>
<settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd'
          xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
   <servers>
        <server>
            <id>bintray-yourusername-maven-yourpackagename</id> <!-- same id with the snapshotRepository -->
            <username>yourusername</username>
            <password>your_api_key</password>
        </server>
    </servers>
    <profiles>
        <profile>
            <repositories>
                <repository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray</name>
                    <url>http://jcenter.bintray.com</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray-plugins</name>
                    <url>http://jcenter.bintray.com</url>
                </pluginRepository>
            </pluginRepositories>
            <id>bintray</id>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>bintray</activeProfile>
    </activeProfiles>
</settings>

【讨论】:

  • 对于阅读此内容的人认为这是正确答案,请记住,此答案不是修复 401 以将 SNAPSHOT 部署到 Bintray。你总是会得到 401 尝试这样做。这个答案实际上展示了如何将 Artifactory 用于 SNAPSHOTs 而不是 Bintray。有关如何在 oss.jfrog.org 等上获取您的帐户的说明,请参阅我的回答。
  • @JBaruch 我想知道为什么这对我有用,哦,是的,我确保工件已链接到 JCenter :-)
  • 你做对了——将快照放入 oss.jfrog.org(参见distribution-management 中的 repo url)。
【解决方案2】:

没有看到您的 pom 文件,我敢打赌,您正在尝试将 SNAPSHOT 上传到 Bintray。 Bintray 是一个分发平台,仅用于发布。

You're more than welcome to use oss.jfrog.org for snapshots of packages, which are included in JCenter.

【讨论】:

    猜你喜欢
    • 2023-03-09
    • 2014-07-03
    • 2016-12-24
    • 1970-01-01
    • 1970-01-01
    • 2018-05-19
    • 1970-01-01
    • 2017-05-26
    • 2021-04-26
    相关资源
    最近更新 更多