mybatis配置文件

<!--任何格式良好的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

 

 

  1. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  2. 声明XML Schema 实例,声明后就可以使用 schemaLocation 属性了

 

xmlns="http://www.springframework.org/schema/beans"  
声明xml文件默认的命名空间,表示未使用其他命名空间的所有标签的默认命名空间

 

  1. xmlns:aop="http://www.springframework.org/schema/aop"  
  2. 声明前缀为aop的命名空间,后面的URL用于标示命名空间的地址不会被解析器用于查找信息。其惟一的作用是赋予命名空间一个惟一的名称。当命名空间被定义在元素的开始标签中时,所有带有相同前缀的子元素都会与同一个命名空间相关联。  

 

 

 

 

目前一些读不通,博客原址:http://www.cnblogs.com/doit8791/p/5757798.html

 

http://www.mybatis.org/spring/zh/factorybean.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值