Programming/Spring

[Spring] springboot mybatis sqlsessionfactory 오류

OriginMaster 2021. 11. 24. 13:03
반응형

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/spring-config.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [com/domain/sql/mapper/UserDao.xml]'; nested exception is java.io.FileNotFoundException: class path resource [com/domain/sql/mapper/UserDao.xml] cannot be opened because it does not exist

이런 에러가날때가 있다.

 

mybatis 설정 xml파일을 보면

 

 

<property name="mapperLocations"  value="classpath:com/test/sql/mapper/*.xml" />

이런식으로 되어있을텐데

 

 

<property name="mapperLocations"     value="classpath*:com/test/sql/mapper/*.xml" />

으로 바꿔주면 된다.

 

classpath뒤에 * 붙여주면 해결.



출처: https://jeekchic.tistory.com/2

 

sqlsessionfactory 오류

인텔리j에서 spring + mybatis 조합에서 mapper.xml 찾지못해 오류일때 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in ServletContex..

jeekchic.tistory.com

 

반응형