Java 无法解析与maven';s层次结构和项目存储库中的自定义
我对maven的层次结构和项目存储库中的自定义存在问题 这是父POM文件:Java 无法解析与maven';s层次结构和项目存储库中的自定义,java,maven,Java,Maven,我对maven的层次结构和项目存储库中的自定义存在问题 这是父POM文件: <project xmlns="http://maven.apache.org/POM/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/1.0.0 http://maven.apache.o
<project xmlns="http://maven.apache.org/POM/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/1.0.0 http://maven.apache.org/xsd/maven-1.0.0.xsd">
<modelVersion>1.0.0</modelVersion>
<groupId>groud-id</groupId>
<artifactId>parent-id</artifactId>
<version>4.0.0</version>
<packaging>pom</packaging>
<properties>
..
</properties>
<modules>
<module>my-common-library</module>
<module>my-module-1</module>
<module>my-module-2</module>
</modules>
<repositories>
<repository>
<id>local-repo</id>
<name>local repo ${}</name>
<url>file://${project.basedir}/../repo</url>
</repository>
</repositories>
</project>
我使用'clean source:jar install'命令在本地存储库中安装了'my common library'模块,并在${user.home}/.m2/repository/文件夹中检查安装是否成功(成功)
尝试通过“clean verify”命令打包模块“my-module-1”时出现错误,即无法在“本地repo”存储库中找到依赖项“my common library”,完全忽略此依赖项在本地存储库上,具体错误为:
[ERROR] Failed to execute goal on project my-module-1: Could not resolve dependencies for project groud-id:my-module-1:war:4.0.0: Failed to collect dependencies at groud-id:my-common-library:jar:4.0.0: Failed to read artifact descriptor for groud-id:my-common-library:jar:4.0.0: Failure to find groud-id:parent-id:pom:4.0.0 in file://D:\dev-customers\customer\workspace\parent-id\my-module-1/../repo was cached in the local repository, resolution will not be reattempted until the update interval of local-repo has elapsed or updates are forced -> [Help 1]
老实说,这是我第一次遇到这种情况,也许是因为这是我第一次尝试使用Maven的层次结构
Maven:3.3.9(嵌入Eclipse)
Java:JDK 1.8.0ď错误消息中明确说明了问题: 在中找不到组id:父id:pom:4.0.0 文件://D:\dev customers\customer\workspace\parent id\my-module-1/。/repo 这意味着它没有为父pom执行
mvn安装
。这需要在存储库中才能正确解析公共模块的依赖关系
如果您从父目录执行mvn安装
,它将首先安装父pom,然后安装所有子模块,如模块所述:
<modules>
<module>my-common-library</module>
<module>my-module-1</module>
<module>my-module-2</module>
</modules>
我的公共图书馆
my-module-1
my-module-2
您还可以在父文件夹中执行
mvn install-N
,这将只安装父pom,而不是所有子模块。您的示例有点难,但它正在尝试查找pom
<代码>找不到groud id:LiveDocsES4:pom:1.0.0…@Eugene是的,但我不知道为什么它可以在${user.home}/.m2/repository/文件夹中解析它。文件在那里!jar
和pom
都在那里,对吗?@Eugene yep,我通过“tree”命令编辑了所有本地存储库结构。所有文件都在那里!什么样的第三方依赖关系?此外,我强烈建议使用存储库管理器。。。
[ERROR] Failed to execute goal on project my-module-1: Could not resolve dependencies for project groud-id:my-module-1:war:4.0.0: Failed to collect dependencies at groud-id:my-common-library:jar:4.0.0: Failed to read artifact descriptor for groud-id:my-common-library:jar:4.0.0: Failure to find groud-id:parent-id:pom:4.0.0 in file://D:\dev-customers\customer\workspace\parent-id\my-module-1/../repo was cached in the local repository, resolution will not be reattempted until the update interval of local-repo has elapsed or updates are forced -> [Help 1]
<modules>
<module>my-common-library</module>
<module>my-module-1</module>
<module>my-module-2</module>
</modules>