XXXMapper.xml 위치 지정(classpath* 사용해야함 * ← 있어야함)
root-context.xml
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
// dataSource
sqlSessionFactory.setDataSource(dataSource());
// MyBatis Configuration
org.apache.ibatis.session.Configuration mybatisConfig = new org.apache.ibatis.session.Configuration();
mybatisConfig.setMapUnderscoreToCamelCase(true);
sqlSessionFactory.setConfiguration(mybatisConfig);
// mapper location
sqlSessionFactory.setMapperLocations(
new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/**/*.xml"));
return (SqlSessionFactory) sqlSessionFactory.getObject();
}
RootConfig.java
<bean id="sqlSessionFactory"
class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configuration" ref="mybatisConfig" />
<property name="mapperLocations"
value="classpath*:mapper/**/*.xml" />
</bean>
검색이 힘들면 공식문서가 최고다
728x90
'Spring' 카테고리의 다른 글
| Spring 3.1.1 RELEASE CORS Filter (0) | 2024.07.23 |
|---|---|
| Spring MVC Project 안보일 때 (0) | 2024.06.21 |
| Spring Legacy pom.xml 초기설정 (0) | 2024.06.03 |
| moa(3) (0) | 2024.02.22 |
| moa(1) (0) | 2024.02.15 |