spring로 검색한 결과 :: 시소커뮤니티[SSISO Community]
 
SSISO 카페 SSISO Source SSISO 구직 SSISO 쇼핑몰 SSISO 맛집
추천검색어 : JUnit   Log4j   ajax   spring   struts   struts-config.xml   Synchronized   책정보   Ajax 마스터하기   우측부분

회원가입 I 비밀번호 찾기


SSISO Community검색
SSISO Community메뉴
[카페목록보기]
[블로그등록하기]  
[블로그리스트]  
SSISO Community카페
블로그 카테고리
정치 경제
문화 칼럼
비디오게임 스포츠
핫이슈 TV
포토 온라인게임
PC게임 에뮬게임
라이프 사람들
유머 만화애니
방송 1
1 1
1 1
1 1
1 1
1

spring로 검색한 결과
등록일:2020-01-17 14:23:06
작성자:
제목:Spring - Autowiring 관련 오류


spring - Autowiring 관련 오류

Bean을 찾지 못해서 발생하는 오류

아래와 같이 Bean이 없다면서 Autowiring이 안 되는 경우가 있다.

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

Description:

Field xxxRepository in yyyService required a bean of type '어쩌구.XXXRepository' that could not be found.


Action:

Consider defining a bean of type '어쩌구.XXXRepository' in your configuration.

ComponentScan or scanBasePackages

일반적으로는 @ComponentScan(basePackages = {}) 또는 @springBootApplication(scanBasePackages = {})로 해당 Bean이 존재하는 패키지를 지정해주면 된다.

@springBootApplication(scanBasePackages = {"어쩌구가속한적당한패키지"})
public class XXXApplication {

JPA Repository인 경우

JPA Repository일 때는 @EnableJpaRepositories(basePackages = {})를 확인한다. XXXRepository 클래스가 속한 패키지가 지정되어 있지 않은 상태일 것이다. 적절히 패키지를 지정해주면 된다.

Not a managed type

JPA 엔티티 클래스에 대해 다음과 같은 에러가 날 때가 있다.

Caused by: java.lang.IllegalArgumentException: Not a managed type: class 어쩌구.XXX

이 때는 @EntityScan(basePackages = {})를 확인한다. XXX 엔티티 클래스가 속한 패키지가 지정되어 있지 않은 사앹일 것이다. 적절히 패키지를 지정해주면 된다.