Skip to content

Commit 7924e18

Browse files
Updated Mapper Scanning process to take advantage of MyBatis-Spring
1.2.0 features.
1 parent 393daa3 commit 7924e18

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.mybatis3.config;
2+
3+
import org.mybatis.spring.annotation.MapperScan;
4+
import org.springframework.context.annotation.Configuration;
5+
6+
/**
7+
* @author Siva
8+
*
9+
*/
10+
@Configuration
11+
@MapperScan("com.mybatis3.mappers")
12+
public class AppConfig
13+
{
14+
15+
}

chapter05/src/main/resources/applicationContext.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
xmlns:context="http://www.springframework.org/schema/context"
66
xmlns:p="http://www.springframework.org/schema/p"
77
xmlns:tx="http://www.springframework.org/schema/tx"
8+
xmlns:mybatis="http://mybatis.org/schema/mybatis-spring"
89
xsi:schemaLocation="http://www.springframework.org/schema/beans
910
http://www.springframework.org/schema/beans/spring-beans.xsd
1011
http://www.springframework.org/schema/aop
1112
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
1213
http://www.springframework.org/schema/context
1314
http://www.springframework.org/schema/context/spring-context.xsd
1415
http://www.springframework.org/schema/tx
15-
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
16+
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
17+
http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd">
1618

1719
<context:annotation-config />
1820

@@ -27,9 +29,11 @@
2729
<property name="dataSource" ref="dataSource" />
2830
</bean>
2931

30-
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
32+
<!-- <mybatis:scan base-package="com.mybatis3.mappers" /> -->
33+
34+
<!-- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
3135
<property name="basePackage" value="com.mybatis3.mappers" />
32-
</bean>
36+
</bean> -->
3337

3438
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
3539
<constructor-arg index="0" ref="sqlSessionFactory" />

0 commit comments

Comments
 (0)