Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为maven设置新的本地人工制品?_Maven_Build_Repository_Build Automation_Artifactory - Fatal编程技术网

如何为maven设置新的本地人工制品?

如何为maven设置新的本地人工制品?,maven,build,repository,build-automation,artifactory,Maven,Build,Repository,Build Automation,Artifactory,我已经阅读了很多关于这个网站和其他网站的问题和文章,但我仍然无法让它工作 我已将maven配置为执行构建,现在希望将工件放入存储库中。我在tomcat中安装了artifactory,它似乎正在工作 如果执行“mvn clean install”,则消息表明工件正在上载到本地maven存储库,而不是artifactory: [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ my-app --- [INFO] Inst

我已经阅读了很多关于这个网站和其他网站的问题和文章,但我仍然无法让它工作

我已将maven配置为执行构建,现在希望将工件放入存储库中。我在tomcat中安装了artifactory,它似乎正在工作

如果执行“mvn clean install”,则消息表明工件正在上载到本地maven存储库,而不是artifactory:

[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ my-app ---
[INFO] Installing C:\maven_projects\my-app\my-app\target\my-app-1.0-SNAPSHOT.jar to             C:\Users\Administrator\.m2\repository\com\mycompany\app\my-app\1.0
-SNAPSHOT\my-app-1.0-SNAPSHOT.jar
[INFO] Installing C:\maven_projects\my-app\my-app\pom.xml to     C:\Users\Administrator\.m2\repository\com\mycompany\app\my-app\1.0-SNAPSHOT\my-app-1.0-SNAPSHOT.pom
如果我执行一个“mvn deploy:deploy”文件,指定存储库,则消息表明工件正在上载到artifactory中,但它们不在那里:

mvn deploy:deploy-file -DrepositoryId=libs-release-local -Durl=http://localhost:8080/artifactory/libs-release-local -D
groupId=com.mycompany.app -DartifactId=my-app -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=target/my-app-1.0-SNAPSHOT.jar

[...]

[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy-file (default-cli) @ my-app ---
Downloading: http://localhost:8080/artifactory/libs-release-local/com/mycompany/app/my-app/1.0-SNAPSHOT/maven-metadata.xml
Uploading: http://localhost:8080/artifactory/libs-release-local/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-20130202.014428-1.jar
Uploading: http://localhost:8080/artifactory/libs-release-local/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-20130202.014428-1.pom
POM.XML文件是:

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>my-app</name>
  <url>http://maven.apache.org</url>
  <repositories>
                      <repository>
                              <id>central</id>
                      <url>http://localhost:8080/artifactory/libs-release</url>
                      <snapshots>
                              <enabled>false</enabled>
                      </snapshots>
              </repository>
              <repository>
                      <id>snapshots</id>
                      <url>http://localhost:8080/artifactory/libs-snapshot</url>
                      <releases>
                              <enabled>false</enabled>
                      </releases>
              </repository>
      </repositories>
      <pluginRepositories>
              <pluginRepository>
                      <id>central</id>
                      <url>http://localhost:8080/artifactory/plugins-release</url>
                      <snapshots>
                              <enabled>false</enabled>
                      </snapshots>
              </pluginRepository>
              <pluginRepository>
                      <id>snapshots</id>
                      <url>http://localhost:8080/artifactory/plugins-snapshot</url>
                      <releases>
                              <enabled>false</enabled>
                      </releases>
              </pluginRepository>
      </pluginRepositories>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <distributionManagement>
<repository>
        <id>sademo</id>
        <name>sademo-releases</name>
        <url>http://localhost:8080/artifactory/ext-release-local</url>
    </repository>
    <snapshotRepository>
        <id>sademo</id>
        <name>sademo-snapshots</name>
        <url>http://localhost:8080/artifactory/ext-snapshot-local</url>
    </snapshotRepository>
</distributionManagement>
</project>

4.0.0
com.mycompany.app
我的应用程序
罐子
1.0-快照
我的应用程序
http://maven.apache.org
中心的
http://localhost:8080/artifactory/libs-释放
假的
快照
http://localhost:8080/artifactory/libs-快照
假的
中心的
http://localhost:8080/artifactory/plugins-释放
假的
快照
http://localhost:8080/artifactory/plugins-快照
假的
朱尼特
朱尼特
3.8.1
测试
萨德莫
萨德莫释放
http://localhost:8080/artifactory/ext-本地发布
萨德莫
萨德莫快照
http://localhost:8080/artifactory/ext-快照本地
settings.xml文件是:

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0         http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <servers>
    <server>
      <username>admin</username>
      <password>password</password>
      <id>sademo</id>
</server>
    <server>
      <username>admin</username>
      <password>password</password>
      <id>sademo-releases</id>
    </server>
  </servers>
  <mirrors>
    <mirror>
      <mirrorOf>*</mirrorOf>
      <name>remote-repos</name>
      <url>http://localhost:8080/artifactory/remote-repos</url>
      <id>remote-repos</id>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>sademo</id>
          <name>libs-release</name>
          <url>http://localhost:8080/artifactory/libs-release</url>
        </repository>
        <repository>
          <snapshots />
          <id>sademo-snapshots</id>
          <name>libs-snapshot</name>
          <url>http://localhost:8080/artifactory/libs-snapshot</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>plugins-release</name>
          <url>http://localhost:8080/artifactory/plugins-release</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>plugins-snapshot</name>
          <url>http://localhost:8080/artifactory/plugins-snapshot</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

管理
密码
萨德莫
管理
密码
萨德莫释放
*
远程回购
http://localhost:8080/artifactory/remote-回购协议
远程回购
假的
萨德莫
libs发布
http://localhost:8080/artifactory/libs-释放
萨德莫快照
libs快照
http://localhost:8080/artifactory/libs-快照
假的
中心的
插件发布
http://localhost:8080/artifactory/plugins-释放
快照
插件快照
http://localhost:8080/artifactory/plugins-快照
人工制品
人工制品
关于如何让“mvn干净安装”将jar上传到Artificatory中,有什么想法吗?

在maven中

mvn install
用于将工件安装到本地存储库中,而不是安装到远程存储库中。 要将工件上载到远程存储库,您需要说:

mvn deploy
mvn部署将使用distributionManagement中的条目将工件上载到给定的存储库

在您的示例中,pom不应该包含存储库的任何配置,因为您已经在settings.xml文件中完成了此操作

除此之外,您的配置似乎不是100%正确,原因是:

Uploading: http://localhost:8080/artifactory/libs-release-local/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-20130202.014428-1.jar
Uploading: http://localhost:8080/artifactory/libs-release-local/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-20130202.014428-1.pom
显示工件放入的位置。在本例中,libs release local,但工件是快照的,而不是发布的

我要说的是改变以下几点:

<repository>
  <snapshots />
  <id>sademo-snapshots</id>
  <name>libs-snapshot</name>
  <url>http://localhost:8080/artifactory/libs-snapshot</url>
</repository>

萨德莫快照
libs快照
http://localhost:8080/artifactory/libs-快照
进入:


真的
萨德莫快照
libs快照
http://localhost:8080/artifactory/libs-快照
<repository>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
  <id>sademo-snapshots</id>
  <name>libs-snapshot</name>
  <url>http://localhost:8080/artifactory/libs-snapshot</url>
</repository>