gpt4 book ai didi

java - 无法解决 Maven 多模块项目中的依赖关系

转载 作者:行者123 更新时间:2023-12-02 03:19:53 26 4
gpt4 key购买 nike

尽管还有其他问题,但我还是发布了这个问题。然而,到目前为止我还没有找到任何解决方案,因此发布这个问题。

我收到此错误:

Could not resolve dependencies for project vehicle-tracker:vehicle-simulator:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at vehicle-tracker:common-libs:jar:0.0.1-SNAPSHOT: Failed to read artifact descriptor for vehicle-tracker:common-libs:jar:0.0.1-SNAPSHOT: Could not find artifact vehicle-tracker:vehicle-tracker:pom:0.0.1-SNAPSHOT

common-libs jar 可以在

下找到
.m2\repository\vehicle-tracker\common-libs\0.0.1-SNAPSHOT

我尝试构建的项目依赖于 common-libs jar,但在本地 Maven 存储库中找不到 Maven。

我附上以下 POM.xml

Parent.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>
<groupId>vehicle-tracker</groupId>
<artifactId>vehicle-tracker</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<modules>
<module>common-libs</module>
<module>vehicle-simulator</module>
<module>tracker-dashboard</module>
</modules>

</project>

Common-libs POM.xml

<?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>
<parent>
<groupId>vehicle-tracker</groupId>
<artifactId>vehicle-tracker</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../vehicle-tracker</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>common-libs</artifactId>
<name>common-libs</name>
<description>Common libraries for vehicle tracker</description>

<properties>
<java.version>1.8</java.version>
</properties>

<dependencies>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

车辆模拟器 POM.xml

<?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>
<parent>
<groupId>vehicle-tracker</groupId>
<artifactId>vehicle-tracker</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../vehicle-tracker/</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>vehicle-simulator</artifactId>
<name>vehicle-simulator</name>
<description>vehicle simulator for application</description>

<properties>
<java.version>1.8</java.version>
<swagger-version>2.9.2</swagger-version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger-version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger-version}</version>
</dependency>

<dependency>
<artifactId>common-libs</artifactId>
<version>0.0.1-SNAPSHOT</version><!--${project.version}-->
<groupId>vehicle-tracker</groupId><!-- ${project.groupId} -->
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

我无法找到我在 POM 中出错的地方或其他地方......因此无法构建项目车辆跟踪器。

最佳答案

我解决了构建错误。实际上我把下面的内容放在 common-libs 模块的 POM.xml 中:

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

这应该位于 commons-lib 模块的 POM.xml 中,因为它正在创建 spring-boot jar。因此,依赖关系对于依赖模块不可用。从 commons-lib 模块中删除 POM.xml 中的此配置 block 后,我可以毫无问题地构建项目。

感谢大家对此的关注。如果有人有意或无意地面临这一问题,请分享此信息。

关于java - 无法解决 Maven 多模块项目中的依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56934142/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com