我有多模块的弹簧引导项目。根项目是"BookStore",子模块是"api“。我尝试在“书店”中的"api“类中使用。但我有错误:
一个评估项目':api‘的问题。在项目':api‘中找不到带路径的项目’:书店‘。
我的根settings.gradle:
pluginManagement {
plugins {
id 'org.springframework.boot' version "2.3.3.RELEASE"
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
}
}
rootProject.name = 'BookStore'
include 'api'根的build.gradle:
plugins {
id 'org.springframework.boot'
id 'io.spring.dependency-management'
id 'java'
id 'idea'
}
allprojects {
group = 'com.aleksandr'
version = '1.0-SNAPSHOT'
description = 'BookStore'
}
subprojects {
repositories {
mavenCentral()
}
apply {
plugin("io.spring.dependency-management")
}
}
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
}
dependencies {
implementation project(':api')
}和子模块的build.gradle:
plugins {
id 'org.springframework.boot'
id 'io.spring.dependency-management'
id 'java'
id 'idea'
}
repositories {
mavenCentral()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
}
dependencies {
compile project(":BookStore")
implementation 'org.springframework.boot:spring-boot-starter-web'
}我做错了什么?如何从根模块获得类?
发布于 2020-11-30 20:10:45
如果需要从子项目(此处为api)到rootProject创建依赖项,则必须使用以下依赖符号之一:
子模块build.gradle
dependencies {
api(project(":")) // ":" is the identifier for the rootProject
// OR
api(rootProject) // "rootProject" varible points to the root Project instance.
}但是在您的示例中还有另一个问题:您正在rootProject和api子项目之间创建一个依赖周期,这是不允许的。
海事组织,您的api子项目不应该依赖根项目。
https://stackoverflow.com/questions/65078403
复制相似问题