Maven 无法解析同一个多模块项目中模块的依赖关系 [英] Maven cannot resolve dependency for module in same multi-module project

查看:22
本文介绍了Maven 无法解析同一个多模块项目中模块的依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行

mvn dependency:build-classpath

mvn exec:java

Maven 无法解决我的一个模块对另一个模块的依赖.

Maven is unable to resolve a dependency of one of my modules on another.

[错误] 无法在项目解析器应用程序上执行目标:无法解析项目 project_group:A:jar:0.1-SNAPSHOT: 找不到工件 project_group:B:jar:0.1-SNAPSHOT

[ERROR] Failed to execute goal on project parser-app: Could not resolve dependencies for project project_group:A:jar:0.1-SNAPSHOT: Could not find artifact project_group:B:jar:0.1-SNAPSHOT

项目结构如下:

/pom.xml
/A/pom.xml
/B/pom.xml

父pom如下:

<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>project_group</groupId>
  <artifactId>parent</artifactId>
  <packaging>pom</packaging>
  <version>0.1-SNAPSHOT</version>
  <name>parent</name>

  <modules>
    <module>A</module>
    <module>B</module>
  </modules>

第一个子模块(无法解析依赖的那个):

The first child module (the one failing to resolve the dependency):

    <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>parent_group</groupId>
    <artifactId>parent</artifactId>
    <version>0.1-SNAPSHOT</version>
  </parent>
  <artifactId>A</artifactId>
  <packaging>jar</packaging>
  <name>A</name>

  <dependencies>
    <dependency>
      <groupId>parent_group</groupId>
      <artifactId>B</artifactId>
      <version>0.1-SNAPSHOT</version>
    </dependency>

第二个子模块(依赖):

The second child module (the dependency):

  <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>parent_group</groupId>
    <artifactId>parent</artifactId>
    <version>0.1-SNAPSHOT</version>
  </parent>
  <artifactId>B</artifactId>
  <packaging>jar</packaging>
  <name>B</name>

推荐答案

您是否至少在项目上运行了一次 mvn clean install 以在本地存储库中安装依赖项?

Have you run mvn clean install at least once on the project to install the dependencies within your local repository?

这篇关于Maven 无法解析同一个多模块项目中模块的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆