skip to Main Content

spirngboot 3.3.1 + JDK17;

Problem occurred during migration from Springboot 2.7 to 3.3

my build.gradle.kts

enter image description hereplugins {
    id("java")
    id("org.springframework.boot") version "3.3.1"
    id("io.spring.dependency-management") version "1.1.5"
}

group = "back.ecommerce"
version = "0.0.1-SNAPSHOT"

java {
    sourceCompatibility = JavaVersion.VERSION_17
}

configurations {
    compileOnly {
        extendsFrom(configurations.annotationProcessor.get())
    }
}

repositories {
    mavenCentral()
    maven {
        setUrl("https://jitpack.io")
    }
}

dependencyManagement {
    imports {
        mavenBom("io.awspring.cloud:spring-cloud-aws-dependencies:2.4.4")
    }
}
dependencies {
    implementation("org.springframework.boot:spring-boot-starter-data-jpa")
    implementation("org.springframework.boot:spring-boot-starter-web")
    implementation("org.springframework.boot:spring-boot-starter-validation")


    // Logback Appender Discord
    implementation("org.slf4j:slf4j-api:1.7.25")
    implementation("com.github.napstr:logback-discord-appender:1.0.0")
    implementation("net.logstash.logback:logstash-logback-encoder:7.3")

    //Auth JWT
    implementation("org.springframework.security:spring-security-crypto")
    implementation("io.jsonwebtoken:jjwt:0.9.1")

    //queryDSL
    implementation("com.querydsl:querydsl-jpa:5.0.0")
    annotationProcessor("com.querydsl:querydsl-apt:5.0.0")
    annotationProcessor("jakarta.annotation:jakarta.annotation-api")
    annotationProcessor("jakarta.persistence:jakarta.persistence-api")


    //AOP
    implementation("org.springframework.boot:spring-boot-starter-aop")

    //AWS SQS
    implementation("io.awspring.cloud:spring-cloud-starter-aws-messaging")

    //Redis
    implementation("org.springframework.boot:spring-boot-starter-data-redis")

    //spring docs
    implementation("org.springdoc:springdoc-openapi-ui:1.6.15")

    //webflux(REST API Client)
    implementation("org.springframework.boot:spring-boot-starter-webflux")
    testImplementation("io.projectreactor:reactor-test")

    annotationProcessor("org.projectlombok:lombok")
    compileOnly("org.projectlombok:lombok")

    runtimeOnly("com.mysql:mysql-connector-j")
    testRuntimeOnly("com.h2database:h2")

    testImplementation("org.springframework.boot:spring-boot-starter-test")
}

tasks.test {
    useJUnitPlatform()
}

val querydslDir = file("build/generated/querydsl")

tasks.compileJava {
    options.generatedSourceOutputDirectory.set(querydslDir)
    doFirst {
        querydslDir.mkdirs()
    }
}

sourceSets["main"].java {
    srcDir("build/generated/querydsl")
}

enter image description here

To migrate to Springboot 3.0, I have newly written from gadle.build to gardle.build.kts

Because the existing entity code is Java code, we used annotationProcessor instead of KPAT plugin.

//queryDSL
implementation("com.querydsl:querydsl-jpa:5.0.0")
annotationProcessor("com.querydsl:querydsl-apt:5.0.0")
annotationProcessor("jakarta.annotation:jakarta.annotation-api")
annotationProcessor("jakarta.persistence:jakarta.persistence-api")

I expecting generated QClass

2

Answers


  1. There are so many solutions to solve this problem.

    I also have the same problem with you at exact same version of Java and Spring boot version.

    Have you tried to check the version of JDK in your IDE?

    Solution 1.

    • Press Ctrl + Alt + S and search gradle to check gradle configuration
    • check GradleJVM. It should be the same version with your JDK

    Solution 2.

    • Press Ctrl + Alt + Shift + S and find project settings
    • check SDK at Project and Modules. It should be the same version with your JDK

    Solution 3. (If you are Windows user)

    • If you use multiple versions of JDK, sometimes environment variable crushes with the JDK.
    • Set same JDK at environment variable

    Solution 4.

    • Sometimes your git log has crush of it
    • Delete local brach having problem and checkout the branch again

    I solved the problem with those kind of solutions.

    Login or Signup to reply.
  2. Spring Boot 3+ based on Jakarta EE, so you should add classifier to querydsl-apt:

    annotationProcessor("com.querydsl:querydsl-apt:5.0.0:jakarta")
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search