首页 > 解决方案 > 无法在 intelij 的 gradle 项目中引用其他模块

问题描述

我在一个项目中创建了一个相对较新的项目,其中包含 4 个模块(使用 intelij 创建)。但是,我现在已经到了要从另一个(app-updater)导入一个模块(:domain)的阶段。我面临的问题是,当我在 intelij 中执行此操作时,它会在“构建:同步”选项卡中出现错误。这很奇怪,因为当我将“compile project(':domain')”行添加到 build.gradle 时,我的模块 app-updater 能够引用模块域,而当我删除该行时,我遇到了缺少类的问题,所以构建:同步似乎正在工作它只是从 intelij 内部运行它似乎给出了一个错误,说“在根项目 'app-updater' 中找不到具有路径':域'的项目。” 我在下面附上了我的 gradle 配置,

主项目settings.gradle文件

rootProject.name = 'rGuide'

include 'domain'
include 'service'
include 'app-updater'
include 'app-rest'

:domain build.gradle

group 'domain'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    // https://mvnrepository.com
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.0.1'
    compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.9.9'
    compile group: 'commons-lang', name: 'commons-lang', version: '2.6'

    testCompile group: 'junit', name: 'junit', version: '4.12'
}

应用更新程序 build.gradle 文件

group 'app-updater'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
    google()
    maven {
        url 'https://repo.spring.io/plugins-release/'
    }
    maven {
        url 'https://repo.spring.io/milestone'
    }
}

dependencies {
    compile project(':domain')

    // https://mvnrepository.com
    compile group: 'net.ser1', name: 'gozirra-client', version: '0.4.1'

    compile group: 'io.netty', name: 'netty-all', version: '4.1.36.Final'
    compile group: 'io.projectreactor.netty', name: 'reactor-netty', version: '0.9.0.M2'

    compile group: 'org.springframework.integration', name: 'spring-integration-stomp', version: '5.1.6.RELEASE'
    compile group: 'org.springframework.integration', name: 'spring-integration-core', version: '5.1.6.RELEASE'
    compile group: 'org.springframework', name: 'spring-context', version: '5.1.6.RELEASE'
    compile group: 'org.springframework', name: 'spring-web', version: '5.1.6.RELEASE'
    compile group: 'org.springframework', name: 'spring-websocket', version: '5.1.6.RELEASE'

    compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.9'

    testCompile group: 'junit', name: 'junit', version: '4.12'
}

TLDR - 尝试将域导入 intelij 中的应用程序更新程序,它“工作正常”并且似乎导入域但是当我使用 intelij 中的“构建:同步”选项卡执行此操作时,它会给出错误消息“带有路径的项目”:域“可以在根项目 'app-updater' 中找不到。”。谢谢你的帮助!! Intelij 图像

标签: javagradleintellij-idea

解决方案


推荐阅读