반응형
@Autowired 로 주입한 객체가 null이라고 뜨는 경우
-> 의존성 주입이 제대로 되지 않음.
객체를 @Autowired로 주입한 클래스를
new로 생성하였는지 확인한다.
-> 클래스를 new로 생성하지 말고 @Autowired로 주입시켜 사용하자.
참고))
https://rimkongs.tistory.com/256
[Spring] @Autowired 한 class가 null로 나오는 문제 해결법 (Spring 의존성 주입 문제)
우리는 보통 bean에 의존성 주입을 하고 싶을 때, @Autowired 를 사용하는데요. @Autowired한 class 가 null 이 나왔다는 건, 해당 클래스에 의존성 주입이 제대로 이루어지지 않았다는 것입니다. Spring에서
rimkongs.tistory.com
반응형
'코딩 관련 > Spring 관련' 카테고리의 다른 글
Springboot에서 STOMP 구현하기 / springboot stomp 예시 / spring boot websocket stomp / STOMP 메세지 테스트 예시 (0) | 2024.02.17 |
---|---|
[Springboot][JAVA] springboot로 websocket 구현하기 (0) | 2024.02.13 |
Springboot JPA 연동 / postgreSQL JPA 연동 (0) | 2023.02.09 |
springboot H2 연동하기 / JPA 사용하기 (0) | 2023.01.27 |
[Spring][Maven] maven 프로젝트 외부 라이브러리 추가하기 (0) | 2022.06.08 |