我在构建 Maven 模块时遇到问题。我遵循基于模块的架构,我有一个名为 Bikewale 的父项目,它的子模块名为 Bike-repo、Bike-service 和 Bike-web。当我尝试在 Bike-service 的 pom 文件中添加 Bike-repo 依赖项时,我面临 Maven Build Failure 错误说:
[ERROR] Failed to execute goal on project Bike-service: Could not resolve dependencies for project ab.sp:Bike-service:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at ab.sp:Bike-repo:jar:0.0.1-SNAPSHOT: Failed to read artifact descriptor for ab.sp:Bike-repo:jar:0.0.1-SNAPSHOT: Could not find artifact ab.sp:Bikewale:pom:0.0.1-SNAPSHOT -> [Help 1]
尽管我在我的 .m2 存储库中检查了 Bike-repo 是否存在,并且它存在于那里。在我以前的项目中,我没有遇到这个问题。
自行车回购的 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ab.sp</groupId>
<artifactId>Bikewale</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>Bike-repo</artifactId>
</project>
自行车服务的 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ab.sp</groupId>
<artifactId>Bikewale</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>Bike-service</artifactId>
<dependencies>
<dependency>
<groupId>ab.sp</groupId>
<artifactId>Bike-repo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>