<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:util="http://www.springframework.org/schema/util" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    xmlns:cache="http://www.springframework.org/schema/cache"
    xsi:schemaLocation="  
        http://www.springframework.org/schema/context  
        http://www.springframework.org/schema/context/spring-context.xsd  
        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/jdbc  
        http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd  
        http://www.springframework.org/schema/cache  
        http://www.springframework.org/schema/cache/spring-cache-3.1.xsd  
        http://www.springframework.org/schema/aop  
        http://www.springframework.org/schema/aop/spring-aop.xsd  
        http://www.springframework.org/schema/util  
        http://www.springframework.org/schema/util/spring-util.xsd">

<!-- 自动扫描 -->
    <context:component-scan base-package="com.exayong">
        <context:exclude-filter type="annotation"
            expression="org.springframework.stereotype.Controller" />
    </context:component-scan>

<!-- 配置使Spring采用CGLIB代理 -->
    <aop:aspectj-autoproxy proxy-target-class="true" />

<!-- 启用对事务注解的支持 -->
    <tx:annotation-driven transaction-manager="transactionManager"
        proxy-target-class="true" />

<!-- 对dataSource 数据源进行事务管理 -->
    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
        p:dataSource-ref="dataSource" />

<!-- dataSource 配置 -->
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
        init-method="init" destroy-method="close">
        <property name="driverClassName">
            <value>com.mysql.jdbc.Driver</value>
        </property>
        <!-- 基本属性 url、user、password -->
        <property name="url" value="jdbc:mysql://localhost:3306/arc1?useUnicode=true&amp;characterEncoding=UTF-8" />
        <property name="username" value="root" />
        <property name="password" value="" />

<!-- 配置初始化大小、最小、最大 -->
        <property name="initialSize" value="1" />
        <property name="minIdle" value="1" />
        <property name="maxActive" value="20" />

<!-- 配置获取连接等待超时的时间 -->
        <property name="maxWait" value="60000" />

<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
        <property name="timeBetweenEvictionRunsMillis" value="60000" />

<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
        <property name="minEvictableIdleTimeMillis" value="300000" />

<property name="validationQuery" value="SELECT 'x'" />
        <property name="testWhileIdle" value="true" />
        <property name="testOnBorrow" value="false" />
        <property name="testOnReturn" value="false" />

<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
        <property name="poolPreparedStatements" value="false" />
        <property name="maxPoolPreparedStatementPerConnectionSize"
            value="20" />

<!-- 配置监控统计拦截的filters -->
        <property name="filters" value="stat" />
    </bean>

<!-- mybatis文件配置,扫描所有mapper文件 -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
        p:dataSource-ref="dataSource" p:configLocation="classpath:mybatis-config.xml"
        p:mapperLocations="classpath:com/exayong/**/*Mapper.xml" />

<!-- spring与mybatis整合配置,扫描所有dao 自动实现 有 @Repository 的才会扫-->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
        p:basePackage="com.exayong"
        p:annotationClass="org.springframework.stereotype.Repository"
         />

</beans>

spring 配置 applicationContext.xml的更多相关文章

  1. web.xml中配置Spring中applicationContext.xml的方式

    2011-11-08 16:29 web.xml中配置Spring中applicationContext.xml的方式 使用web.xml方式加载Spring时,获取Spring applicatio ...

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

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

  3. Spring的applicationContext.xml文件

    以下是详解Spring的applicationContext.xml文件代码:<!-- 头文件,主要注意一下编码 --><?xml version="1.0" e ...

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

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

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

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

  6. Spring 配置文件applicationContext.xml

    Spring配置文件是用于指导Spring工厂进行Bean生产.依赖关系注入(装配)及Bean实例分发的"图纸". Spring配置文件是一个或多个标准的XML文档,applica ...

  7. web.xml中配置spring配置(application.xml)文件

    application.xml 一般放到WEB-INF下,当然,你也可以将它放到任意问题,但需要web.xml指向到该文件 1.application.xml配置 <?xml version=& ...

  8. spring的applicationContext.xml如何自动加载

    一个web工程自动加载的配置文件只有web.xml,想要加载其他.xml必须在web.xml里面进行配置. 用spring的时候需要一个bean容器来管理所有的bean,所有bean默认是写在appl ...

  9. spring的applicationContext.xml中的DBCP配置如下:

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy ...

随机推荐

  1. Android+Struts2实现简单的前后台交互--Android网络编程

    1.下面测试截图,基本过程就是:点击按钮向服务器端发送请求,后台收到请求后给出返回的数据,前台只需要显示服务端数据就可以了.例子很简单能但引发很多思考,博主学了杂七杂八的,这又在来想杂学Android ...

  2. LeetCode--342--4的幂

    问题描述: 给定一个整数 (32 位有符号整数),请编写一个函数来判断它是否是 4 的幂次方. 示例 1: 输入: 16 输出: true 示例 2: 输入: 5 输出: false 进阶:你能不使用 ...

  3. Confluence 6 为一个空间应用一个主题

    主题允许你对 Confluence 的外表和显示进行自定义.你的 Confluence 空间管理员可以到 The Atlassian Marketplace 上下载主题. 一旦一个主题被安装到 Con ...

  4. php数组的逐行写入文件与读取

    <?php /** * * 对数组$arr1=['Apple Orange Banana Strawberry'] 写入文件,并读取 **/ class IoFile { private $pa ...

  5. Sphinx实时索引

    数据库中的数据很大,然后我有些新的数据后来加入到数据库中,也希望能够检索到,全部重新建立索引很消耗资源,这样需要用到“主索引+增量索引”的思路来解决,这个模式实现的基本原理是设置两个数据源和两个索引. ...

  6. 【洛谷p1106】删数问题

    (洛谷t2755暂时过不去了) 删数问题[传送门] 洛谷算法标签: emmmm……删数问题又牵扯到了字符串.因为毕竟高精度的数240位呢!要是输入一个整型,要码240行来求出每一位……怕是还没求出来就 ...

  7. jquery 根据自定义属性选择

    <div myattr="test">text</div> 使用$("div[myattr='test']")进行选择

  8. mybatis中的mapper接口文件以及selectByExample类的实例函数详解

    记录分为两个部分,第一部分主要关注selectByExample类的实例函数的实现:第二部分讨论Mybatis框架下基本的实例函数. (一)selectByExample类的实例函数的实现 当你启动项 ...

  9. 使用telnet模拟邮件的收发

    smtp协议是一个简单的邮件传输协议,利用它我们可以将邮件发送给别人,这里将通过telnet这个程序利用smtp协议从网易向gmail发送一封邮件 基本步骤如下: 1.使用telnet连接smtp服务 ...

  10. 关于react16.4——转发refs和片段Fragment

    1.转发refs Ref 转发是一种自动将 ref 通过组件传递给子组件的技术. 一些组件倾向于以与常规 DOM button 和 input 类似的方式在整个应用程序中使用, 并且访问他们的 DOM ...