Maven从artifactory部署的JARS在作为依赖项给出时不会被下载

时间:2016-04-23 16:27:10

标签: maven maven-3

我使用maven创建了一个jar文件,并将其部署到本地神器中。我可以看到jar文件和pom in artifactory

<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.hr</groupId>
<artifactId>hotel-schema</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<parent>
    <groupId>com.mycompany.hr</groupId>
    <artifactId>spring-ws</artifactId>
    <version>1</version>
</parent>

<name>jaxb-schema Spring-WS Application</name>
<url>http://www.springframework.org/spring-ws</url>
<build>
    <finalName>hotel-schema</finalName>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>2.2</version>
            <executions>
                <execution>
                    <id>xjc</id>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                </execution>

            </executions>
            <configuration>
                <!-- The package of your generated sources -->
                <sources>
                    <source>../holidayService/src/main/xsd</source>
                </sources>
                <packageName>com.example.myschema</packageName>
                <outputDirectory>target/generated-sources/jaxb</outputDirectory>
            </configuration>

        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>2.2</version>
    </dependency>
</dependencies>

<distributionManagement>
    <repository>
        <id>central</id>
        <name>Babu-Dell-releases</name>
        <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>Babu-Dell-snapshots</name>
        <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </snapshotRepository>
</distributionManagement>
</project>

然而,当我尝试将jar作为依赖项添加到另一个项目时,它没有被下载。我没有看到任何错误。

<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>com.mycompany.hr</groupId>
    <artifactId>spring-ws</artifactId>
    <version>1</version>
</parent>
<artifactId>holidayService</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>holidayService Spring-WS Application</name>
<url>http://www.springframework.org/spring-ws</url>
<repositories>
    <repository>
        <id>my-internal-site</id>
        <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </repository>
</repositories>
<build>
    <finalName>holidayService</finalName>
    <extensions>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-ftp</artifactId>
            <version>2.10</version>
        </extension>
    </extensions>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>tomcat-maven-plugin</artifactId>
            <version>1.1</version>
        </plugin>
    </plugins>
</build>
<dependencies>


    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
        <version>2.1.4.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>jaxen</groupId>
        <artifactId>jaxen</artifactId>
        <version>1.1.6</version>
    </dependency>
    <dependency>
        <groupId>org.jdom</groupId>
        <artifactId>jdom</artifactId>
        <version>2.0.2</version>

    </dependency>

    <dependency>
        <groupId>com.mycompany.hr</groupId>
        <artifactId>hotel-schema</artifactId>
        <version>1.0</version>
    </dependency>

</dependencies>

<distributionManagement>
    <repository>
        <id>central</id>
        <name>Babu-Dell-releases</name>
        <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>Babu-Dell-snapshots</name>
        <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </snapshotRepository>
</distributionManagement>
</project>

请帮忙

请在我的本地存储库[本地存储库的图像] [1]

中找到附加图像

另请参阅以下settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
  <username>admin</username>
  <password>{YBoEnaZCnnEHquaMcfJGpTjh0I7i+vQAv9a2+CQL9ZE=}</password>
  <id>central</id>
</server>
<server>
  <username>admin</username>
  <password>{YBoEnaZCnnEHquaMcfJGpTjh0I7i+vQAv9a2+CQL9ZE=}</password>
  <id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>libs-release</name>
      <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </repository>
    <repository>
      <snapshots />
      <id>snapshots</id>
      <name>libs-snapshot</name>
      <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>plugins-release</name>
      <url>http://localhost:8081/artifactory/plugins-release</url>
    </pluginRepository>
    <pluginRepository>
      <snapshots />
      <id>snapshots</id>
      <name>plugins-snapshot</name>
      <url>http://localhost:8081/artifactory/plugins-snapshot</url>
    </pluginRepository>
  </pluginRepositories>
  <id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>

Image of eclipse maven dependencies

Artifactory server jar file image

2 个答案:

答案 0 :(得分:1)

我觉得你在这里有些困惑。您可能在本地安装了artifactory,并且正确配置了maven settings.xml以指向它,但是在屏幕截图中,您向我们展示了.m2文件夹下的maven本地存储库。

他们是Gerold已经说过的两个不同的存储库。

如果您希望您的工件继续使用您的LOCAL仓库(即您的.m2 / repository文件夹),您必须调用mvn安装目标,而将工件部署到REMOTE artifactory,您必须调用maven部署目标并拥有{{ 3}}在项目中配置,告诉项目在哪里部署。

如果您只想在本地工作,则无需安装工件,只需使用本地存储库(maven将为您提供开箱即用的功能,因此您可以删除设置中的所有其他存储库部分.xml和distributionManagement部分。

Artifactory对团队工作非常有用,但不应在本地托管,而应在所有团队成员都可以访问的共享服务器上托管。 在任何情况下,如果您想使用它,您应该从其Web界面检查工件是否已正确部署。

最后,正如已经提到的那样,这是在&#34; mvn clean deploy&#34;之后出现的错误。命令?可能有很多原因导致工件本地安装(根据您的屏幕截图)但不远程(在神器上)

答案 1 :(得分:0)

显示您的配置文件未启用,默认情况下将其设为活动状态,或者在配置文件中输入id并在命令中附加-PprofileId,它应该下载。