에러 모음

[Spring Framework] BeanDefinitionParsingException

junani0v0 2024. 6. 7. 00:06

< 에러 메시지 >

SEVERE: Context initialized 이벤트를 [org.springframework.web.context.ContextLoaderListener] 클래스의 인스턴스인 리스너에 전송하는 동안 예외 발생

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unexpected failure during bean definition parsing

Offending resource: file [C:\dev\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\pf_jun01\WEB-INF\classes\context-beans.xml]

Bean ''; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Multiple 'property' definitions for property 'basePackage'

Offending resource: file [C:\dev\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\pf_jun01\WEB-INF\classes\context-beans.xml]

 

BeanDefinitionParsingException

XML 파일을 구문 분석하는 동안 발생할 수 있는 오류

- 잘못된 XML 구문

- 잘못된 빈 정의

- 파일 누락

< 원인 >

<!-- DAO 위치를 basePackage로.. -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.portfolio.www.auth.mybatis" />
    <property name="basePackage" value="com.portfolio.www.forum.notice.mybatis" />
</bean>

"context-beans.xml" 파일에서 'basePackage' 속성에 대해 여러 번의 'property' 정의가 있어서 발생

< 해결 >

 

<!-- DAO 위치를 basePackage로.. -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> 
    <property name="basePackage" value="com.portfolio.www.**.mybatis" />
</bean>

여러개 선언이 불가하다면 

와일드 카드 패턴을 사용하여 0개 이상의 하위 패키지를 포함하도록 변경하여 해결