Nexus Pro 可以创建暂存存储库,但上传时出现 401 未授权失败



我有一个小项目,我用在 stagin pl

[INFO]  * Remote staging into staging profile ID "29ad9cd35d5f3"
[INFO]  * Created staging repository with ID "bizaqutebnd-1010".
[INFO]  * Staging repository at http://localhost:8081/nexus/service/local/staging/deployByRepositoryId/bizaqutebnd-1010
[INFO]  * Uploading locally staged artifacts to profile biz.aQute.bnd
Uploading: http://localhost:8081/nexus/service/local/staging/deployByRepositoryId/bizaqutebnd-1010/biz/aQute/bnd/test.maven/1.0.1/test.maven-1.0.1.pom.asc
[ERROR] Remote staging finished with a failure: Failed to deploy artifacts: Could not transfer artifact biz.aQute.bnd:test.maven:pom.asc:1.0.1 
    from/to local (http://localhost:8081/nexus/service/local/staging/deployByRepositoryId/bizaqutebnd-1010): 
    Failed to transfer file: http://localhost:8081/nexus/service/local/staging/deployByRepositoryId/bizaqutebnd-1010/biz/aQute/bnd/test.maven/1.0.1/test.maven-1.0.1.pom.asc. 
    Return code is: 401, ReasonPhrase: Unauthorized.

由于我可以创建暂存存储库,因此我获得权限似乎是不可避免的。使用 curl 命令测试上传:

curl -u admin:admin123 -x put -h 内容类型:foo --data @pom.xml http://localhost:8081/nexus/service/local/staging/deployByRepositoryId/bizaqutebnd-1009/biz/aQute/bnd/test.maven/1.0.1/test.maven-1.0.1.pom.asc

成功无误。

完全不解...

事实证明,当使用Java进行通信时,Nexus的反应非常不同。此问题已通过将用户代理标头设置为 Java 默认值以外的其他内容来修复。

可能Nexus有一些针对旧Maven版本的向后兼容性代码。

最新更新