我按照https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages#authenticating-to-github-packages上的说明进行操作,但无法获得mvn install
来下载工件。
错误类似于:
[ERROR] Failed to execute goal on project myproject: Could not resolve dependencies for project com.project:myproject:jar:1.0: Failed to collect dependencies at com.dependency:mydependency:jar:0.1.331: Failed to read artifact descriptor for com.dependency:mydependency:jar:0.1.331: Could not transfer artifact com.dependency:mydependency:pom:0.1.331 from/to github (https://maven.pkg.github.com/OWNER/REPO): Failed to transfer file: https://maven.pkg.github.com/OWNER/REPO/com/dependency/mydependency/0.1.331/mydependency-0.1.331.pom. Return code is: 400 , ReasonPhrase:Bad Request. -> [Help 1]
答案 0 :(得分:0)
在浏览器中打开URL并提供GitHub用户名和访问令牌显示此错误:
Unable to download maven package : "GraphQL call failed: Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes: ['read:packages'], but your token has only been granted the: ['admin:gpg_key', 'admin:org', 'admin:org_hook', 'admin:public_key', 'admin:repo_hook', 'delete_repo', 'gist', 'notifications', 'repo', 'user'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens."
修复权限后,mvn install
目标才能正确完成。