- Arawn's Dev Blog
- Outsider's Dev Story
- Toby's Epril
- Benelog
- NHN 개발자 블로그
- SK 플래닛 기술 블로그
- OLC CENTER
- 소프트웨어 경영/공학 블로그
- 모바일 컨버전스
- KOSR - Korea Operating System …
- 넥스트리 블로그
- 리버스코어 ReverseCore
- SLiPP
- 개발자를 위하여... (Nextree 임병인 수석)
- "트위터 부트스트랩: 디자이너도 놀라워할 매끈하고 직관…
- Learning English - The English…
- real-english.com
- 'DataScience/Deep Learning' 카테…
- Deep Learning Summer School, M…
- Deep Learning Courses
민서네집
MyBatis 사용시 주의점 본문
1) "Mapped Statements collection does not contain value ...." 이라는 오류가 발생하는 경우.
다음 세가지가 일치해야 한다.
interface 파일명, Quert가 XML로 들어있는 mapper file, mapper namespace
[원문]
The three names have to match:
- interface = com.enlliance.inventory.mappers.SettingMapper.class
- mapper file = /com/enlliance/inventory/mappers/SettingMapper.xml
- mapper namespace = com.enlliance.inventory.mappers.SettingMapper
If they don't match, it won't work.
2) org.mybatis.spring.mapper.MapperScannerConfigurer 를 등록하려고 하는데, basePackage 하위의 service의 interface도 ibatis의 DAO 빈으로 인식하는 오류가 발생하는 경우.
<!-- scan for mappers and let them be autowired -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.sample.mgmt" />
<property name="annotationClass" value="org.springframework.stereotype.Repository"/>
</bean>
위에서처럼 annotationClass 속성을 추가해주고, DAO interface의 경우 @Repository 를 붙여주면 된다.
[출처] http://stackoverflow.com/questions/8999597/mybatis-spring-configuration-cant-autowire-mapper-beans
3) mybatis의 typeAliasClass를 하나의 디렉터리가 아니라 여러 개의 디렉터리로 분산시켜서 놓고 싶은 경우.
<!-- define the SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="com.sample.mgmt" />
</bean>
위에서처럼 typeAliasesPackage 속성을 주면 이 하위 디렉터리의 클래스들은 모두 myBatis Mapper XML에서 parameter type 이나 result Type으로 사용할 수 있다.
'Spring' 카테고리의 다른 글
Transaction 설정 파일 (0) | 2013.07.05 |
---|---|
WebApplication 에서 Spring Bean 가져오기 (0) | 2013.05.06 |
Java Custom Annotation Example (0) | 2013.04.23 |
Spring MVC From Handling Annotation Example (0) | 2013.04.23 |
Spring 과 myBatis 통합하기 (0) | 2013.04.23 |