spring interface dao<->xml mapper 연동을 위한 MapperScannerConfigurer 설정
interface와 xml연동 설정시 다중 세션을 사용하는 경우 mapper scan 시 자신이 사용할 세션을 정의 하기 위해
xml 및 dao에 아래와 같이 설정 합니다.
임의의 scan인터페이스를 생성 합니다.
context-mapper.xml에 mapper설정시 아래와 같이 scan을 지정 합니다.
mapper생성시 해당 스캐너를 사용 할 수 있게 지정 해줍니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | package egovframework.cmmn; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.stereotype.Component; @Target ({ElementType.TYPE}) @Retention (RetentionPolicy.RUNTIME) @Documented @Component public @interface AddMapperScan { String value() default "" ; } |
1 2 3 4 5 | < bean class = "egovframework.rte.psl.dataaccess.mapper.MapperConfigurer" > < property name = "basePackage" value = "mapper.add" ></ property > < property name = "annotationClass" value = "egovframework.cmmn.AddMapperScan" ></ property > < property name = "sqlSessionFactoryBeanName" value = "addSqlSession" ></ property > </ bean > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | package egovframework.mapper.sky; import java.util.HashMap; import java.util.List; import egovframework.cmmn.SkyMapperScan; import egovframework.cmmn.service.UserVO; import egovframework.rte.psl.dataaccess.mapper.Mapper; import egovframework.rte.psl.dataaccess.util.EgovMap; import egovframework.sub.sendReport.service.OpenDeptVO; import egovframework.sub.sendReport.service.OpenPersonVO; @AddMapperScan @Mapper ( "addOpenMapper" ) public interface AddOpenMapper { List<tempvo> selectList(String tempStr) throws Exception; List<tempvo> selectOpenList(HashMap<string,string> paramMap) throws Exception; List<tempvo> selectList() throws Exception; EgovMap selectInfo(String tempStr) throws Exception; } </tempvo></string,string></tempvo></tempvo> |
반응형
'spring' 카테고리의 다른 글
spring csrf 데이터 확인 (0) | 2021.04.30 |
---|---|
ajax 전송시 415에러 발생 (0) | 2021.04.30 |
@Valid 사용시 xml 변경 및 jar파일 (0) | 2017.02.10 |
aspect bofore 관련 (0) | 2016.07.01 |
sessionFactory annotatedClasses/packagesToScan 방식 (0) | 2015.07.27 |