<!--任何格式良好的xml文档都必须第一行是声明。相当于告诉解析器这个是xml文档,你给我用xml解析器解析-->
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:bean="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!--配置该属性后,sqlSessionFactory会自动扫描该路径下的所有文件并解析
该路径支持多个,可以用,;\t\n进行分割
每一个路径都可以用直接的包路径,或者Ant风格的表达式。-->
<property name="mapperLocations" value="classpath:mapper/*.xml"/>
<!--该属性可以配置MyBatis的拦截器,拦截器的配置顺序会影响拦截器的执行顺序 -->
<property name="plugins">
<array>
<!-- 分页查询(mybatis 3.2.8以上版本)-张晗-->
<bean class="com.github.pagehelper.PageInterceptor">
<property name="properties">
<value>
helperDialect=mysql
</value>
</property>
</bean>
</array>
</property>
</bean>
<!-- DAO接口所在包名,Spring会自动查找其下的类 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!--basePackage可以写多个,可以用,;\t\n进行分割。-->
<property name="basePackage" value="com.dmsdbj.itoo.achievement.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
</beans>
https://zhidao.baidu.com/question/400011963.html?qbl=relate_question_3
http://blog.csdn.net/wangshfa/article/details/26471641
http://blog.csdn.net/isea533/article/details/45640319
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!--配置该属性后,sqlSessionFactory会自动扫描该路径下的所有文件并解析
该路径支持多个,可以用,;\t\n进行分割
每一个路径都可以用直接的包路径,或者Ant风格的表达式。-->
<property name="mapperLocations" value="classpath:mapper/*.xml"/>
<!--该属性可以配置MyBatis的拦截器,拦截器的配置顺序会影响拦截器的执行顺序 -->
<property name="plugins">
<array>
<!-- 分页查询(mybatis 3.2.8以上版本)-张晗-->
<bean class="com.github.pagehelper.PageInterceptor">
<property name="properties">
<value>
helperDialect=mysql
</value>
</property>
</bean>
</array>
</property>
</bean>
<!-- DAO接口所在包名,Spring会自动查找其下的类 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!--basePackage可以写多个,可以用,;\t\n进行分割。-->
<property name="basePackage" value="com.dmsdbj.itoo.achievement.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
</beans>
https://zhidao.baidu.com/question/400011963.html?qbl=relate_question_3
http://blog.csdn.net/wangshfa/article/details/26471641
http://blog.csdn.net/isea533/article/details/45640319
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- 声明XML Schema 实例,声明后就可以使用 schemaLocation 属性了
xmlns="http://www.springframework.org/schema/beans"
声明xml文件默认的命名空间,表示未使用其他命名空间的所有标签的默认命名空间
- xmlns:aop="http://www.springframework.org/schema/aop"
- 声明前缀为aop的命名空间,后面的URL用于标示命名空间的地址不会被解析器用于查找信息。其惟一的作用是赋予命名空间一个惟一的名称。当命名空间被定义在元素的开始标签中时,所有带有相同前缀的子元素都会与同一个命名空间相关联。
目前一些读不通,博客原址:http://www.cnblogs.com/doit8791/p/5757798.html
http://www.mybatis.org/spring/zh/factorybean.html