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"
}
}
Top comments (0)