3

When trying to add spring-boot-starter-data-jpa to my project through gradle, it just doesn't do it. The @Entity tag doesn't work and the jar doesn't appear in the project and external dependencies folder. There's no error unless I put in the @Entity tag. Here is my gradle file for reference.

plugins {
    id 'org.springframework.boot' version '2.3.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'java'
}
group = 'com.Hype'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '14'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version:
    '2.3.4.RELEASE'
    implementation 'org.springframework.boot:spring-boot-starter-data-rest'
    implementation 'org.springframework.boot:spring-boot-starter-jdbc'
    implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
    implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-web-services'
    implementation 'org.springframework.session:spring-session-jdbc'
    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'mysql:mysql-connector-java'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    testImplementation 'org.springframework.security:spring-security-test'

}

test {
    useJUnitPlatform()
}

Before anyone mentions it, yes I've tried cleaning and rebuilding the project multiple times.

double-beep
  • 5,031
  • 17
  • 33
  • 41
  • Please add your answer "SOLVED" as an answer instead of edit to question, then remove it from the question and flag this comment as no longer needed. – Petter Friberg Oct 27 '20 at 08:09

3 Answers3

2

If you are using Gradle 6.x, the compile configuration has been deprecated. Its use has been discouraged since Gradle 3.4. You should use implementation instead. This change would also make this dependency more consistent with the others in your build script. You can learn a bit more about this in the Gradle documentation.

You've also specified a version on the spring-boot-starter-data-jpa dependency. This isn't necessary as the version can be determined by the version of the Spring Boot plugin that you've applied. This is what's happening with the other dependencies in your script where no version is declared. It makes it easier to keep all of the versions in sync.

In short, try updating the dependency declaration to look like the following:

implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
Andy Wilkinson
  • 108,729
  • 24
  • 257
  • 242
  • This is what I had originally before I looked at https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa/2.3.4.RELEASE It still doesn't work unfortunately. – David Kostandin Oct 27 '20 at 07:56
0

SOLVED: The issue was in Spring tool suite, using Project->Clean wasn't updating gradle dependencies. Had to right click build.gradle->gradle->refresh gradle project to get everything to update.

0

Following the previous suggestion, in the VS Code cleaning Java project helped me to resolve the issue: Open "Java Project" view -> "..." -> "Clean Workspace"

Depending on VS Code configuration, after the cleaning, the gradle rebuilds dependencies automatically. If not, you can right-click on build.gradle and select "Update Project"

gorden_sh
  • 46
  • 2