< 에러 메시지 >
SEVERE: Context initialized 이벤트를 [org.springframework.web.context.ContextLoaderListener] 클래스의 인스턴스인 리스너에 전송하는 동안 예외 발생
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'noticeController': Unsatisfied dependency expressed through field 'boardService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'boardService': Unsatisfied dependency expressed through field 'boardDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'boardDao' defined in file [C:\dev\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\10_board_self\WEB-INF\classes\com\pf\www\forum\notice\dao\BoardDao.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'dataSource' is required
UnsatisfiedDependencyException
빈을 주입할 때 발생
Spring에서는 빈들 간의 의존성을 자도응로 해결해주는데 이 과정에서 문제가 발생
- 필요한 빈을 찾을 수 없는 경우
- 빈을 주입할 수 없는 경우
< 원인 >
@Autowired
private DataSource dataSource;
BoardDao에서 @Autowired로 DataSource를 가지고 오지 못해 발생 (그렇기에 뒤에서 service와 controller에서도 에러발생)
< 해결 >
@Autowired
public void setDataSource(DataSource dataSource) {
super.setDataSource(dataSource);
}
JdbcTemplate을 상속받고 있기에 JdbcTemplate원하는 형식으로 의존성 주입 필요
dataSource를 조상이 써야하기에 super앞에 붙여줌
'에러 모음' 카테고리의 다른 글
IncorrectResultSizeDataAccessException (0) | 2024.05.15 |
---|---|
PropertyNotFoundException (0) | 2024.05.11 |
CannotLoadBeanClassException (0) | 2024.05.09 |
XmlBeanDefinitionStoreException (0) | 2024.05.09 |
BadSqlGrammarException (0) | 2024.05.09 |