将链接的工件部署$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 是一个分发平台,仅用于发布。