This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); | |
sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:**/*Mapper.xml")); | |
sqlSessionFactoryBean.setTypeHandlersPackage("net.luversof.opensource.mybatis.type"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); | |
sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:**/*Mapper.xml")); | |
List<TypeHandler<?>> typeHandlerlist = new ArrayList<>(); | |
typeHandlerlist.add(new LocalDateTimeTypeHandler()); | |
TypeHandler<?>[] typeHandlers = typeHandlerlist.toArray(new TypeHandler[typeHandlerlist.size()]); | |
sqlSessionFactoryBean.setTypeHandlers(typeHandlers); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.mybatis.spring.boot</groupId> | |
<artifactId>mybatis-spring-boot-starter</artifactId> | |
<version>1.1.1</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); | |
sqlSessionFactoryBean.setVfs(SpringBootVFS.class); | |
sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:**/*Mapper.xml")); | |
sqlSessionFactoryBean.setTypeHandlersPackage("net.luversof.opensource.mybatis.type"); |
이 경우 2번과 같이 일일이 typeHandler를 지정하여 해결할 수도 있다.
mybatis에서는 spring boot 사용시 war에 묶인 path가 /WEB-INF/lib에 묶여 올바른 패스가 인식 되지않는 경우를 위해 SpringBoot용 VFS를 제공한다.
3-1과 같이 mybatis-spring-boot-starter를 참조한 후 3-2와 같이 SpringBootVFS를 설정하면 spring boot에서 mybatis scan 설정이 올바르게 동작한다.
(참고 링크)
해당 문제는 mybatis가 버전업하면서 해결된 듯 하다.
MyBatis Java 8 관련 TypeHandler 설정 불필요
댓글 없음:
댓글 쓰기