JPAQueryFactory를 자동 주입할 수 없는 오류가 발생하고 있습니다. 이 문제를 해결하기 위해 다음과 같은 접근 방법을 시도해 볼 수 있습니다.
1. JPAQueryFactory의 빈을 정의하기: JPAQueryFactory는 Spring Data JPA Querydsl을 사용할 때 자동으로 생성되는 빈이 아닙니다. 따라서 JPAQueryFactory의 빈을 직접 정의해야 합니다. 아래와 같이 @Configuration 어노테이션이 지정된 클래스를 생성하고, JPAQueryFactory 빈을 정의해줍니다.
import com.querydsl.jpa.impl.JPAQueryFactory
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import javax.persistence.EntityManager
class QuerydslConfig {
@Configuration
class QuerydslConfiguration(private val entityManager: EntityManager) {
@Bean
fun jpaQueryFactory(): JPAQueryFactory {
return JPAQueryFactory(entityManager)
}
}
}
2. AdminAcademyDaoCustomImpl에 @Repository 어노테이션 추가: AdminAcademyDaoCustomImpl 클래스에 @Repository 어노테이션을 추가하여 스프링에게 해당 클래스를 빈으로 등록하도록 알려줍니다.
@Repository
class AdminAcademyDaoCustomImpl : AdminAcademyDaoCustom {
// ...
}
'Programing > Spring Boot' 카테고리의 다른 글
| Querydsl 에러 java.lang.NoSuchFieldError: TREATED_PATH (0) | 2023.06.30 |
|---|---|
| 코틀린 QueryDsl 설정 적용하는 방법 (0) | 2023.06.30 |
| 빌드 에러 error: as of release 5, 'enum' is a keyword, and may not be used as an identifier (0) | 2023.06.29 |
| 스프링부트 Pageable 카운트 쿼리 분리 (0) | 2023.06.29 |
| Spring boot Data JPA 엔티티를 DTO로 조회하는 방법 (0) | 2023.06.28 |