root-context.xml (1) Spring에서 Mapper 인식
MyBatis를 사용하려면 Spring에서는 XML Mapper파일을 인식해야만 정상적인 동작이 가능합니다.
그래서 우리는 root-context.xml 안의 내용을 조금 수정해줘서
자동적으로 Mapper파일들을 가져올 수 있게 합니당.
<bean id = "sqlSessionFactory" class = "org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:/mybatis-config.xml"></property>
<property name="mapperLocations" value="classpath:mappers/**/*Mapper.xml"></property>
</bean>
작성된 mappers폴더 내의 파일의 이름이 'Mapper.xml'로 끝나면 자동으로 인식시켜주는 코드입니다.
작성된 코드를 붙여넣는것이 아니고 상황에 맞춰서 폴더이름이나 경로를 바꿀수 있어야 할거같다.
'JAVA > spring' 카테고리의 다른 글
root-context.xml (2) SqlSessionTemplate (0) | 2017.09.11 |
---|---|
JSON 데이터생성 @ResponseBody (0) | 2017.09.08 |
Redirect: (0) | 2017.09.08 |
return 타입이 만들어져 있는 경우에는 (0) | 2017.09.06 |
return 타입이 String인 경우 (0) | 2017.09.06 |
댓글
이 글 공유하기
다른 글
-
root-context.xml (2) SqlSessionTemplate
root-context.xml (2) SqlSessionTemplate
2017.09.11 -
JSON 데이터생성 @ResponseBody
JSON 데이터생성 @ResponseBody
2017.09.08 -
Redirect:
Redirect:
2017.09.08 -
return 타입이 만들어져 있는 경우에는
return 타입이 만들어져 있는 경우에는
2017.09.06