gpt4 book ai didi

java - 我有一个错误,但依赖项包含在 gradle root 和 gradle 模块配置中,为什么?

转载 作者:行者123 更新时间:2023-12-03 05:18:37 26 4
gpt4 key购买 nike

我有根配置 gradle.build

plugins {
id 'org.springframework.boot' version '2.3.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
id 'idea'
}
idea {
project {
languageLevel = 14
}
module {
downloadJavadoc = true
downloadSources = true
}
}
allprojects {
group "ru.otus"
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}
apply plugin: "io.spring.dependency-management"
dependencyManagement {
dependencies {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:2.3.5.RELEASE")
}
dependency("org.projectlombok:lombok:1.18.16")
dependency("org.springframework.shell:spring-shell-starter:2.0.1.RELEASE")
dependency("org.springframework.boot:spring-boot-starter-data-jpa:2.3.5.RELEASE")
dependency("org.flywaydb:flyway-core:6.4.4")
dependency("org.postgresql:postgresql:42.2.16")
dependency("org.hamcrest:hamcrest-core:1.3")
dependency("org.springframework.boot:spring-boot-starter-test:2.3.5.RELEASE")
}
}
configurations.all {
resolutionStrategy {
failOnVersionConflict()
}
resolutionStrategy {
force("javax.servlet:servlet-api:2.4")
force("commons-logging:commons-logging:1.1.1")
force("commons-lang:commons-lang:2.5")
force("org.codehaus.jackson:jackson-core-asl:1.8.8")
force("org.codehaus.jackson:jackson-mapper-asl:1.8.3")
force("org.codehaus.jettison:jettison:1.1")
force("org.javassist:javassist:3.24.0-GA")
force("org.apiguardian:apiguardian-api:1.1.0")
force("org.opentest4j:opentest4j:1.2.0")
}
}
}
并在模块中有 build.gradle
plugins {
id 'java'
}

version = '0.0.1-SNAPSHOT'


dependencies {
implementation group: 'org.springframework.shell', name: 'spring-shell-starter', version: '2.0.1.RELEASE'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter', version: '2.3.5.RELEASE'
implementation group: 'org.flywaydb', name: 'flyway-core', version: '6.4.4'
testCompile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.3.5.RELEASE'
}
下载依赖项并添加 @Entity、@Table @Id 等模型注释后,我有一个错误:找不到符号
@实体
^
符号:实体类
但是我在依赖项中有 spring-boot-starter-jpa,我不知道为什么在模块中我不能使用依赖项。

最佳答案

dependencyManagement您只管理依赖项,如版本、覆盖等。您实际上并未将依赖项添加到项目中。为此使用 dependencies就像你在其他地方使用的一样。

关于java - 我有一个错误,但依赖项包含在 gradle root 和 gradle 模块配置中,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64803317/

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