<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns="http://www.springframework.org/schema/beans"
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/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="tk.mybatis.*.service.impl"/>
  
  <!--ibatis依赖mybatis-->
<bean id="dataSource" class="org.apache.ibatis.datasource.pooled.PooledDataSource">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/mybatis"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
</bean>   <!--sqlSession就是我们经常用来加载Mapper.xml,这里配置把sqlSessionFactory交给Spring容器生命周期管理-->
  <!--需要注意的是
和Spring集成,要确保只能在Service层调用lazy字段方法。(Service层返回到Controller层,再去lazy加载,SqlSession都已经关闭抛出异常了。
-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:mybatis-config.xml"/>
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations">
<array>
<value>classpath:tk/mybatis/**/mapper/*.xml</value>
</array>
</property>
<property name="typeAliasesPackage" value="tk.mybatis.web.model"/>
</bean>
<!--自动扫描所有Mapper接口-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="tk.mybatis.**.mapper"/>
</bean>
</beans>

applicationContext.xml配置Spring样板的更多相关文章

  1. Spring,SpringMvc配置常见的坑,注解的使用注意事项,applicationContext.xml和spring.mvc.xml配置注意事项,spring中的事务失效,事务不回滚原因

    1.Spring中的applicationContext.xml配置错误导致的异常 异常信息: org.apache.ibatis.binding.BindingException: Invalid ...

  2. Spring的配置文件ApplicationContext.xml配置头文件解析

    Spring的配置文件ApplicationContext.xml配置头文件解析 原创 2016年12月16日 14:22:43 标签: spring配置文件 5446 spring中的applica ...

  3. springmvc.xml和applicationContext.xml配置的特点

    1:springmvc.xml配置要点 一般它主要配置Controller的组件扫描器和视图解析器 下为:springmvc.xml文件 <?xml version="1.0" ...

  4. The difference between applicationContext.xml in Spring and xxx-servlet.xml in SpringMVC

    一直搞不明白两者的区别.如果使用了SpringMVC,事实上,bean的配置完全可以在xxx-servlet.xml中进行配置.为什么需要applicationContext.xml?一定必须? 因为 ...

  5. spring的applicationContext.xml配置SessionFactory抛异常

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFa ...

  6. 关于Spring中applicationContext.xml配置错误“org/springframework/transaction/interceptor/TransactionInterceptor”的问题解决

    问题描述: 在配置spring的applicationContext.xml中的默认事务管理器的时候可能会出现这样的错误: Error occured processing XML 'org/spri ...

  7. Spring学习总结(7)——applicationContext.xml 配置文详解

    web.xml中classpath:和classpath*:  有什么区别? classpath:只会到你的class路径中查找找文件; classpath*:不仅包含class路径,还包括jar文件 ...

  8. 第九篇:Spring的applicationContext.xml配置总结

    在前面的一篇日志中,记录了web.xml配置启动的顺序,web启动到监听器ContextLoaderListener时,开始加载spring的配置文件applicationContext.xml(通常 ...

  9. applicationContext.xml配置简介

    这里简单介绍一下spring的配置文件applicationContext.xml中的一些配置的作用. <context:component-scan base-package="&q ...

随机推荐

  1. 第二届强网杯wp

    web web签到 利用了md5碰撞 payload为 param1 =%4d%c9%68%ff%0e%e3%5c%20%95%72%d4%77%7b%72%15%87%d3%6f%a7%b2%1b% ...

  2. 商品详情页系统的Servlet3异步化实践

    http://jinnianshilongnian.iteye.com/blog/2245925 博客分类: 架构   在京东工作的这一年多时间里,我在整个商品详情页系统(后端数据源)及商品详情页统一 ...

  3. [CTSC2018]暴力写挂——边分树合并

    [CTSC2018]暴力写挂 题面不错 给定两棵树,两点“距离”定义为:二者深度相加,减去两棵树上的LCA的深度(深度指到根节点的距离) 求最大的距离. 解决多棵树的问题就是降维了. 经典的做法是边分 ...

  4. [CTSC2010]性能优化

    [CTSC2010]性能优化 循环卷积快速幂 两个注意点:n+1不是2^k*P+1形式,任意模数又太慢?n=2^k1*3^k2*5^k3*7^k4 多路分治!深刻理解FFT运算本质:分治,推式子得到从 ...

  5. 【CF375D】Tree and Queries

    题目大意:给定一棵 N 个节点的有根树,1 号节点为根节点,每个节点有一个颜色.有 M 个询问,每次询问以 i 为根的子树中颜色大于等于 K 的有多少种. 题解:子树询问直接 dfs 序转化成序列问题 ...

  6. request 的介绍使用属性

    上下文:相当于一个容器,保存了 Flask 程序运行过程中的一些信息. Flask中有两种上下文,请求上下文和应用上下文 请求上下文(request context) 在 flask 中,可以直接在视 ...

  7. 扩展方法、委托和Lambda

    举例演化Lambda string[] names ={"Burke", "Connor", "Frank", "Everett& ...

  8. flutte项目命令行打包

    进入自己flutter项目根目录,运行以下命令 flutter build apk #打包安卓 flutter build ios #打包ios 然后会给出一个路径,就是打包完成的apk的位置 bui ...

  9. React学习及实例开发(一)——开始(转载)

    https://www.cnblogs.com/MaiJiangDou/p/9245063.html#4136668 转载 一.构建一个新项目 1.命令行运行如下命令,构建一个新的react项目 np ...

  10. prototype 与 proto的关系是什么:

    __proto__是什么? 我们在这里简单地说下.每个对象都会在其内部初始化一个属性,就是__proto__,当我们访问一个对象的属性 时,如果这个对象内部不存在这个属性,那么他就会去__proto_ ...