从 Maven 部署到 JFrog Artifactory
Deploy from Maven to JFrog Artifactory
我已经在虚拟机上下载并安装了JFrog Artifactory社区版
在我的主机上,当我执行 http://build.local:8081/ 时,我能够看到 JFrog 管理控制台。我在Artifactory中创建了一个测试用户,并授予该用户所有权限
在我的主机上,我创建了一个 java maven 项目。我的 POM.xml 看起来像
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abhi</groupId>
<artifactId>HelloWorld</artifactId>
<version>1.0-SNAPSHOT</version>
<distributionManagement>
<snapshotRepository>
<id>MyJFrog</id>
<name>MyJFrogArtifactory</name>
<url>http://build.local:8081/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
</project>
更改了我的 ~/.m2/settings.xml
<servers>
<server>
<username>testuser</username>
<password>testpassword</password>
<id>MyJFrog</id>
</server>
</servers>
但是当我这样做时 mvn deploy -e
我仍然得到错误
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project HelloWorld: Failed to deploy artifacts: Could not transfer artifact com.abhi:HelloWorld:jar:1.0-20151013.153708-1 from/to MyJFrog (http://build.local:8081/libs-snapshot-local): Access denied to: http://build.local:8081/libs-snapshot-local/com/abhi/HelloWorld/1.0-SNAPSHOT/HelloWorld-1.0-20151013.153708-1.jar, **ReasonPhrase: Forbidden.**
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
我在互联网上做了很多研究。大多数人提到了代理问题。但我在一台机器上。 build.local 是我在主机文件中创建的一个条目,指向虚拟机的 IP。所以这里不涉及代理。
我能够解决问题。我上面的 distributionManagement 设置是错误的。
在 JFrog Artifactory 中进入 Artifacts -> libs snapshot local -> Set me up
在这里您将看到分配管理的正确设置。
我已经在虚拟机上下载并安装了JFrog Artifactory社区版
在我的主机上,当我执行 http://build.local:8081/ 时,我能够看到 JFrog 管理控制台。我在Artifactory中创建了一个测试用户,并授予该用户所有权限
在我的主机上,我创建了一个 java maven 项目。我的 POM.xml 看起来像
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abhi</groupId>
<artifactId>HelloWorld</artifactId>
<version>1.0-SNAPSHOT</version>
<distributionManagement>
<snapshotRepository>
<id>MyJFrog</id>
<name>MyJFrogArtifactory</name>
<url>http://build.local:8081/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
</project>
更改了我的 ~/.m2/settings.xml
<servers>
<server>
<username>testuser</username>
<password>testpassword</password>
<id>MyJFrog</id>
</server>
</servers>
但是当我这样做时 mvn deploy -e
我仍然得到错误
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project HelloWorld: Failed to deploy artifacts: Could not transfer artifact com.abhi:HelloWorld:jar:1.0-20151013.153708-1 from/to MyJFrog (http://build.local:8081/libs-snapshot-local): Access denied to: http://build.local:8081/libs-snapshot-local/com/abhi/HelloWorld/1.0-SNAPSHOT/HelloWorld-1.0-20151013.153708-1.jar, **ReasonPhrase: Forbidden.**
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
我在互联网上做了很多研究。大多数人提到了代理问题。但我在一台机器上。 build.local 是我在主机文件中创建的一个条目,指向虚拟机的 IP。所以这里不涉及代理。
我能够解决问题。我上面的 distributionManagement 设置是错误的。
在 JFrog Artifactory 中进入 Artifacts -> libs snapshot local -> Set me up
在这里您将看到分配管理的正确设置。