我使用 maven 创建了一个 jar 文件并将其部署到本地工件工厂。我可以在工件工厂中看到jar文件和pom
<?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]
另外,请在下面找到设置.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>
eclipse maven 依赖项的图像
项目服务器 jar 文件映像
你在这里有点混乱。您可能在本地安装了工件工厂,并且正确配置了 maven 设置.xml指向它,但在屏幕截图中,您向我们展示了 .m2 文件夹下的 maven 本地存储库。
正如 Gerold 已经指出的那样,它们是 2 个不同的存储库。
如果你想让你的工件进入你的本地存储库(即你的.m2/repository文件夹),你必须调用mvn安装目标,而要将你的工件部署到远程工件工厂,你必须调用maven部署目标,并在你的项目中配置一个distributionManagement,告诉项目在哪里部署。
如果您只想在本地工作,则无需安装artifactory,只需使用本地存储库(maven将为您开箱即用,因此您可以删除设置中的所有附加存储库部分.xml以及distributionManagement部分。
Artifactory 对于团队合作非常有用,但不应托管在本地,而应托管在所有团队成员都可以访问的共享服务器上。无论如何,如果要使用它,则应从其Web界面检查工件是否已正确部署。
最后,正如已经问到的,您在"mvn 干净部署"命令后遇到的错误是什么? 工件在本地安装(根据您的屏幕截图)而不是远程安装(在工件工厂上)可能有很多原因
似乎您的配置文件未启用,默认情况下将其设置为活动状态,否则将 id 提供给配置文件并在命令中附加 -PprofileId,它应该下载。