基于注释的更新:
<distributionManagement>
<repository>
<id>releases</id>
<name>Releases</name>
<url>https://mycompany.jfrog.io/artifactory/my-app-libs-release</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Snapshots</name>
<url>https://mycompany.jfrog.io/artifactory/my-app-libs-snapshot/</url>
</snapshotRepository>
</distributionManagement>原版:
我的目标是处理端到端的maven存储库部署和依赖项导入。
我正在努力将maven项目(项目名为my-app)工件部署到jFrog中,然后将工件作为依赖项添加到另一个maven项目(项目名是我的第二个应用程序)。
我已经用account
~/.m2/下安装了jFrog
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>make-a-jar</id>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>
${project.build.directory}/${project.artifactId}-${project.version}.jar
</file>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<generatePom>true</generatePom>
<url>https://mycompany.jfrog.io/artifactory/my-app-libs-release</url>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
</configuration>
</execution>
</executions>
</plugin>当我运行mvn install时,项目会显示401个未经授权的错误,但是工件是部署的,可以在jFrog包中找到。
<dependency>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>0.0.6-SNAPSHOT</version>
</dependency>

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default) on project my-app: Failed to retrieve remote metadata com.mycompany.app:my-app:0.0.6-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.mycompany.app:my-app:0.0.6-SNAPSHOT/maven-metadata.xml from/to remote-repository (https://myurl.jfrog.io/artifactory/my-app-libs-release): authentication failed for https://mycompany.jfrog.io/artifactory/my-app-libs-release/com/mycompany/app/my-app/0.0.6-SNAPSHOT/maven-metadata.xml, status: 401 Unauthorized -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException有人知道我错过了什么吗?为什么我得到401未经授权的错误?我已经在settings.xml中添加了凭据,我的理解是在项目级别上不需要添加任何凭据。
如能提供任何帮助,我们将不胜感激。
发布于 2021-10-25 17:54:49
Maven配置了内置的默认设置,在大多数情况下都能工作,标准的Maven感知存储库服务器(如Nexus和Artifactory )将以最小的配置与它们一起工作。
去掉maven-deploy-plugin的自定义配置,让它使用默认设置。相反,为服务器添加一个带有repository的repository部分,并确保您的~/.m2/settings.xml文件中有匹配的凭据。
发布于 2022-07-13 07:00:18
在我的例子中,重点是id:repository.id和server.id必须是相同的。
pom.xml:
<distributionManagement>
<repository>
<id>cloud-3party</id>
<name>cloud-3party</name>
<url>xxx</url>
</repository>
</distributionManagement>apaphe-maven-3.6.3/conf/seting.xml
<server>
<id>cloud-3party</id>
<username>xxx</username>
<password>xxx</password>
</server>https://stackoverflow.com/questions/69712014
复制相似问题