Spring boot 3, Hibernate ERROR Caused by: java.lang.ClassNotFoundException: Could not load requested class

김주혁's avatar
Jun 06, 2024
Spring boot 3, Hibernate ERROR  Caused by: java.lang.ClassNotFoundException: Could not load requested class
 
Spring 3.0 + JPA + QueryDsl프로젝트를 새롭게 구성하면서 Hibernate 관련 에러가 계속해서 발생했는데,
 
위 에러도 같은 설정문제로서,
jpa: database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
를 사용해서 내가 설치한 Spring boot 및 Hibernate 등 패키지와 버전이 호환되지 않아 발생하는 문제로
 
jpa: database-platform: org.hibernate.dialect.MySQLDialect
 
로 수정해주면 해결된다.
 
사용한 패키지는 아래와 같다.
buildscript { ext { queryDslVersion = "5.0.0" } } plugins { id 'java' id 'org.springframework.boot' version '3.0.6' id 'io.spring.dependency-management' version '1.1.0' id 'org.asciidoctor.convert' version '1.5.8' id "com.ewerk.gradle.plugins.querydsl" version "1.0.10" } group = 'io' version = '0.0.1-SNAPSHOT' java { sourceCompatibility = '17' } configurations { compileOnly { extendsFrom annotationProcessor } } ext { set('snippetsDir', file("build/generated-snippets")) set('springCloudVersion', "2022.0.2") } repositories { mavenCentral() } if (!project.hasProperty('profile') || !profile) { ext.profile = 'local' } dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-aop' implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'org.springframework.boot:spring-boot-starter-data-redis' implementation 'org.springframework.boot:spring-boot-test-autoconfigure' implementation 'org.springframework.boot:spring-boot-starter-cache' implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-starter-logging' testImplementation 'org.springframework.boot:spring-boot-starter-test' annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' developmentOnly 'org.springframework.boot:spring-boot-devtools' // db runtimeOnly 'com.mysql:mysql-connector-j' implementation 'com.zaxxer:HikariCP:5.0.1' implementation 'org.hibernate.orm:hibernate-core:6.0.2.Final' implementation group: 'org.javassist', name: 'javassist', version: '3.15.0-GA' implementation 'org.apache.commons:commons-pool2:2.11.1' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta" annotationProcessor "jakarta.annotation:jakarta.annotation-api" annotationProcessor "jakarta.persistence:jakarta.persistence-api" // 파싱 implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1' implementation 'com.googlecode.json-simple:json-simple:1.1.1' // jwt implementation 'io.jsonwebtoken:jjwt-api:0.11.5' implementation 'com.nimbusds:nimbus-jose-jwt:9.31' runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5' runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5' // aws implementation 'io.awspring.cloud:spring-cloud-starter-aws:2.4.4' // getter, setter 등.. compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' // Swagger implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' } tasks.named('test') { useJUnitPlatform() } sourceSets { main { java { srcDirs = ["src/main/java"] } resources { srcDirs = ["src/main/resources", "src/main/java"] } } } def generated = 'src/main/generated' // querydsl QClass 파일 생성 위치를 지정 tasks.withType(JavaCompile) { options.getGeneratedSourceOutputDirectory().set(file(generated)) } // java source set 에 querydsl QClass 위치 추가 sourceSets { main.java.srcDirs += [ generated ] } // gradle clean 시에 QClass 디렉토리 삭제 clean { delete file(generated) } tasks.named('test') { outputs.dir snippetsDir useJUnitPlatform() } tasks.named('asciidoctor') { inputs.dir snippetsDir dependsOn test }
Share article

vlogue