maven - 如何在 maven 中使用“dependency:get”插件修复“未授权”错误
问题描述
当我在命令行上使用“dependency:get”插件时,maven 会抛出“未授权”错误。我该如何解决?
我试图在 .m2/settings.xml 中添加我的服务器存储库。我的用户名和密码是正确的。我尝试使用相同的工件和存储库,可以通过 IntelliJ 中的 pom.xml 下载。
这是我的 Maven 命令行,它失败了:
mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get \
-Dartifact=mygroup:myartifact:myversion:aar \
-DremoteRepositories=public::default::my.repository
.m2/setting.xml
<servers>
<server>
<id>public</id>
<username>myuser</username>
<password>mypassword</password>
</server>
</servers>
.m2/plugin-registry.xml
<?xml version="1.0" encoding="UTF-8"?>
<pluginRegistry xsi:schemaLocation="http://maven.apache.org/PLUGIN_REGISTRY/1.0.0 http://maven.apache.org/xsd/plugin-registry-1.0.0.xsd"
xmlns="http://maven.apache.org/PLUGIN_REGISTRY/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<useVersion>3.1.1</useVersion>
<rejectedVersions/>
</plugin>
</plugins>
</pluginRegistry>
我的 pom.xml,它成功了:
<dependency>
<groupId>mygroup</groupId>
<artifactId>myartifact</artifactId>
<version>myversion</version>
<type>aar</type>
</dependency>
<repositories>
<repository>
<id>public</id>
<name>Public Repositories</name>
<layout>default</layout>
<url>my.repository</url>
</repository>
</repositories>
解决方案
推荐阅读
- sql - Postgres查询具有不同列值的行的结果
- javascript - Firebase 云功能中不能有嵌套路由
- php - 从mysql拉出后无法选择链接推送到下一页
- python - 从 python 代码将命令重定向到 gnome-terminal
- spring-data-rest - 无论如何提供自定义 PagedResourcesAssembler 实现?
- python - 我需要帮助在 Mac 上加载 TensorBoard
- windows - 如何从命令行转储/恢复硬盘分区表(Bash)
- pyspark - Spark Streaming 调度最佳实践
- python - Python 字母数字和字符比较
- node.js - Firebase 在 Nodejs 中处理事务