삽질 기록-error

Parameter 1 of constructor in com.example.spring_subject.service.CommentService required a bean of type 'com.example.spring_subject.dto.CommentResponseDto' that could not be found.

숲별 2022. 10. 19. 20:18
728x90
Parameter 1 of constructor in com.example.spring_subject.service.CommentService required a bean of type 'com.example.spring_subject.dto.CommentResponseDto' that could not be found.


Action:

Consider defining a bean of type 'com.example.spring_subject.dto.CommentResponseDto' in your configuration.

 

 

 

https://velog.io/@agugu95/%EC%97%90%EB%9F%AC%EC%B2%98%EB%A6%AC-Parameter-1-of-constructor-in-1-required-a-bean-of-type-1-that-could-not-be-found

 

에러처리 Parameter 1 of constructor in {1} required a bean of type {1} that could not be found.

Bean Parameter

velog.io

 

 

//CommentService.java
private final CommentResponseDto commentResponseDto;

제거함..

Dto는 안되는 거..?

 

private final로 의존성 주입하는 건데

스프링에서 관리하는 빈만 의존성 주입 가능
Dto는 빈이 아니라서 의존성 주입안됨

 

controller는 @Restcontroller로

repository는 JpaRepository로 상속받으면서 빈 된다고