JCenter - Return 代码是:401,ReasonPhrase:未经授权

JCenter - Return code is: 401, ReasonPhrase: Unauthorized

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

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

解决方案是在工件的 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>

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

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