I have root config 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") } } }
and have build.gradle in module
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' }
After download dependencies and add in models annotations like @Entity, @Table @Id and etc. i have an error: cannot find symbol @Entity ^ symbol: class Entity But i have spring-boot-starter-jpa in dependencies, i don’t know why in module i can’t use dependencies.
Advertisement
Answer
With dependencyManagement
you only manage dependencies like version, overrides etc. you don’t actually add dependencies to a project. For that use dependencies
like you use in the other places.