DEV Community

Mark
Mark

Posted on • Edited on

11

Spring Boot 3 Integrate QueryDsl with Gradle

As the version of Spring Boot goes up to 3.0, the integration method of QueryDsl changes, so I write to share.

The Spring Boot 3 changed namespace from javax to jakarta, QueryDsl will get error java.lang.NoClassDefFoundError:javax/persistence/Entity.

You can use this build.gradel to fix

plugins {
    id 'org.springframework.boot' version '3.0.1' apply false
    id 'io.spring.dependency-management' version '1.1.0' apply false
}

ext {
    querydslVersion = '5.0.0'
}

subprojects {

    apply plugin: 'java'
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'

    group 'com.example'
    version '1.0.0'
    sourceCompatibility = '17'

    repositories {
        mavenLocal()
        mavenCentral()
    }

    dependencies {
        implementation "org.springframework.boot:spring-boot-starter-web"
        implementation "org.springframework.boot:spring-boot-starter-data-jpa"
        implementation "org.springframework.boot:spring-boot-starter-validation"
        runtimeOnly "com.mysql:mysql-connector-j"
        // lombok
        compileOnly "org.projectlombok:lombok"
        annotationProcessor "org.projectlombok:lombok"
        // QueryDSL
        implementation "com.querydsl:querydsl-jpa:${querydslVersion}:jakarta"
        annotationProcessor "com.querydsl:querydsl-apt:${querydslVersion}:jakarta"
        annotationProcessor "jakarta.persistence:jakarta.persistence-api"
        annotationProcessor "jakarta.annotation:jakarta.annotation-api"
    }

}
Enter fullscreen mode Exit fullscreen mode

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay