기존에 사용하던 Spring 3.1에서 3.2.3으로 변경했다. 하는김에 myBatis도 최신으로 변경..
이러다가 그냥 back-end를 다 최신으로 변경하기로 작정하고 작업 진행..
applicationContext.xml 에서 myBatis 설정이 조금 변경되었다.
org.springframework.orm.ibatis.support.SqlMapClientDaoSupport
as of Spring 3.2, in favor of the native Spring support in the Mybatis follow-up project (http://code.google.com/p/mybatis/)
|
org.springframework.orm.ibatis.SqlMapClientFactoryBean
as of Spring 3.2, in favor of the native Spring support in the Mybatis follow-up project (http://code.google.com/p/mybatis/)
|
org.springframework.orm.ibatis.SqlMapClientTemplate
as of Spring 3.2, in favor of the native Spring support in the Mybatis follow-up project (http://code.google.com/p/mybatis/)
|
3.2 버전 이전은 위 클래스를 이용하여 myBatis 설정을 했지만 3.2 이후부터는 불가능하다.
> myBatis configuration codes in applicationContext
1 2 3 4 5 6 7 8 9 10 | <!-- myBATIS 3.2.3 --> < bean id = "sqlSessionFactory" class = "org.mybatis.spring.SqlSessionFactoryBean" > < property name = "dataSource" ref = "dataSource" ></ property > < property name = "configLocation" value = "classpath:resources/SqlMapConfig.xml" ></ property > < property name = "mapperLocations" value = "classpath*:com/openerp/**/*-mapper.xml" ></ property > <!-- not use this transactionFactory because use spring transactionFactory --> < property name = "transactionFactory" > < bean class = "org.mybatis.spring.transaction.SpringManagedTransactionFactory" ></ bean > </ property > </ bean > |
심플하다... SqlMapConfig에 mapper를 일일이 적어주어도 되지만
mapperLocations를 이용하여 패키지 검색으로 자동 매핑되게도 할 수 있고 이게 더 편하다.
또 하나, 기본 설정 그대로 사용하고자 한다면 configLocation을 적지 않아도 된다.
아래는 maven에서의 myBatis 설정에 관련된 코드.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | < properties > <!-- my baits --> < org.mybatis.version >3.2.2</ org.mybatis.version > < org.mybatis.spring.version >1.2.0</ org.mybatis.spring.version > <!-- my baits --> </ properties > < dependencies > <!-- my batis --> < dependency > < groupid >org.mybatis</ groupid > < artifactid >mybatis</ artifactid > < version >${org.mybatis.version}</ version > </ dependency > < dependency > < groupid >org.mybatis</ groupid > < artifactid >mybatis-spring</ artifactid > < version >${org.mybatis.spring.version}</ version > </ dependency > </ dependencies > |
'백엔드 > Spring' 카테고리의 다른 글
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log (0) | 2013.07.19 |
---|---|
myBatis DAO Pattern example (0) | 2013.07.19 |
Spring Framework 3.2.3 Maven으로 한번에 추가하기.. (0) | 2013.07.18 |
Spring 3.2.2 + Tiles 3.0 (0) | 2013.05.22 |
Spring Security 설정. (2) | 2011.08.30 |