[Spring] QueryDSL Parameter 1 of constructor in [ ] required a bean of type '' that could not be found.

Walter Mitty·2023년 6월 26일
0

정말 바보같은 실수...

Error

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 1 of constructor in com.EduCustomRepositoryImpl required a bean of type 'com.blank.QEduInfo' that could not be found.


Action:

Consider defining a bean of type 'com.blank.QEduInfo' in your configuration.


Process finished with exit code 0

Error가 났던 RepositoryImpl Code

@Repository
@RequiredArgsConstructor
public class EduCustomRepositoryImpl implements EduCustomRepository {

    private final JPAQueryFactory queryFactory;
    private final QEduContents eduContents; // < 이부분 주목
    private final QEduInfo eduInfo; // < 이부분 주목

    @Override
    public List<EduListDTO> findEduAllList(Integer userId) {

        List<EduListDTO> result = queryFactory
            .selectFrom(eduContents)
            .leftJoin(eduInfo).on(eduContents.id.eq(eduInfo.contentId))
            .orderBy(eduContents.id.asc())
            .where(eduInfo.userId.eq(userId))
            .transform(groupBy(eduContents.id).list(Projections.constructor(EduListDTO.class,
                eduContents.id, eduContents.title, eduContents.type, eduInfo.percentage)));

        return result;
    }
}

수정한 Success Code

@Repository
@RequiredArgsConstructor
public class EduCustomRepositoryImpl implements EduCustomRepository {

    private final JPAQueryFactory queryFactory;
    private final QEduContents eduContents = QEduContents.eduContents;
    private final QEduInfo eduInfo = QEduInfo.eduInfo;

    @Override
    public List<EduListDTO> findEduAllList(Integer userId) {

        List<EduListDTO> result = queryFactory
            .selectFrom(eduContents)
            .leftJoin(eduInfo).on(eduContents.id.eq(eduInfo.contentId))
            .orderBy(eduContents.id.asc())
            .where(eduInfo.userId.eq(userId))
            .transform(groupBy(eduContents.id).list(Projections.constructor(EduListDTO.class,
                eduContents.id, eduContents.title, eduContents.type, eduInfo.percentage)));

        return result;
    }
}

0개의 댓글