java父pom工件需要远程部署吗?
我有两个项目,项目A&;项目B
项目B是一个多模块项目,其中子模块1-3是JAR,父模块是包装类型pom
module-parent
|- module-child-1
|- module-child-2
|- module-child-3
父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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.group.id</groupId>
<artifactId>module-parent</artifactId>
<packaging>pom</packaging>
<version>2.4.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath />
</parent>
<modules>
<module>module-child-1</module>
<module>module-child-2</module>
<module>module-child-3</module>
</modules>
<properties>
<java.version>1.11</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
在所有其他孩子的pom中。xml文件,我们将<parent>
作为模块父&;对于maven部署插件<skip>
设置为false
<parent>
<groupId>my.group.id</groupId>
<artifactId>module-parent</artifactId>
<version>2.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
此外,module-child-1是一个定义为&;用于模块-child-2和&;模块-child-3
项目A是一个完全独立的普通项目(它不是一个多模块项目),它可以简单地将三个子模块中的任何一个子模块用作其项目中的依赖项
<dependency>
<groupId>my.group.id</groupId>
<artifactId>module-child-2</artifactId> (or module-child-1/module-child-3)
<version>1.0.0-SNAPSHOT</version>
</dependency>
我的问题是,在项目A上运行maven命令dependency:tree
时,当它试图在我的设置中定义的<servers>
中搜索模块父级时,会抛出以下错误。xml文件,即使模块父级的类型为pom
[ERROR] Failed to execute goal on Project-A: Could not resolve dependencies for project my.group.id:Project-A:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at my.group.id:module-child-2:jar:1.0.0-SNAPSHOT: Failed to read artifact descriptor for my.group.id:module-child-2:jar:1.0.0-SNAPSHOT: Could not transfer artifact my.group.id:module-parent:pom:2.4.0-SNAPSHOT from/to MyServer-SNAPSHOT (https://example): Access Denied to: ......., ReasonPhrase:Forbidden.
pom工件也需要远程部署吗?仅部署了3个子模块。我真的需要为单个pom文件部署单独的工件吗
子模块中的代码非常好,但我猜它无法从任何子模块的<parent>
中读取,因此它可能会依赖项目A的<parent>
# 1 楼答案
是的,您也需要部署父POM。没有父POM,Maven无法读取它们。您应该将所有模块(包括父模块)部署到同一个位置