<beans xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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="http://www.springframework.org/schema/beans"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.2.xsd"> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
<property name="ignoreResourceNotFound" value="false"/>
<property name="locations">
<list>
<value>classpath*:/dbConfig.properties</value>
<value>classpath*:/security-config.properties</value>
<value>classpath*:/led_mq_config.properties</value>
</list>
</property>
</bean> <!-- 注解扫描的包 -->
<!-- <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/> -->
<context:component-scan base-package="cn.com.digicube">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- uses @Transactional sign -->
<mvc:annotation-driven/>
<!-- uses @AspectJ sign-->
<aop:aspectj-autoproxy/>
<task:annotation-driven /> <!-- 配置数据源 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init"
destroy-method="close">
<property name="driverClassName" value="${operation.hibernate.driverClassName}"/>
<property name="url" value="${operation.hibernate.connection.url}"/>
<property name="username" value="${operation.hibernate.connection.username}"/>
<property name="password" value="${operation.hibernate.connection.password}"/>
<property name="maxActive" value="256"/>
<property name="initialSize" value="16"/>
<property name="maxWait" value="60000"/>
<property name="minIdle" value="16"/>
<property name="dbType" value="sqlserver"/>
<!--<propenamename="dbType" value = "sqlserver" />--> <property name="timeBetweenEvictionRunsMillis" value="3000"/>
<property name="minEvictableIdleTimeMillis" value="300000"/> <property name="removeAbandoned" value="true"/>
<!-- 打开removeAbandoned功能 -->
<property name="removeAbandonedTimeout" value="1800"/>
<!-- 1800秒,也就是30分钟 -->
<property name="logAbandoned" value="true"/>
<!-- 关闭abanded连接时输出错误日志 --> <property name="validationQuery" value="SELECT 1"/>
<property name="testWhileIdle" value="true"/>
<property name="testOnBorrow" value="false"/>
<property name="testOnReturn" value="false"/>
<!-- mysql 不支持 poolPreparedStatements <propenamename="poolPreparedStatements"
value="true" /> <propenamename="maxPoolPreparedStatementPerConnectionSize"
value="20" /> -->
<!-- 配置过滤器:wall——防注入攻击(WallFilter默认的防注入配置,也可以自己另外配置),stat-监控统计功能 -->
<property name="filters" value="wall,stat"/>
</bean> <bean id="customNamingStrategy" class="cn.telemedias.commons.api.commons.extension.CustomNamingStrategy"></bean>
<!-- 配置hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="namingStrategy" ref="customNamingStrategy"/>
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${operation.hibernate.dialect}</prop>
<!-- <prop key="hibernate.default_schema">${hibernate.default_schema}</prop>-->
<prop key="hibernate.show_sql">${hibernate.connection.show_sql}</prop>
<prop key="hibernate.max_fetch_depth">${hibernate.max_fetch_depth}</prop>
<prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
<prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.format_sql">${hibernate.connection.format_sql}</prop>
<prop key="hibernate.connection.release_mode">after_transaction</prop>
<!--
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.EhCacheRegionFactory</prop>
-->
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.SingletonEhCacheRegionFactory
</prop>
<!-- 二级缓存EhCache配置 -->
<!--<prop key="hibernate.cache.provider_configuration_file_resource_path">ehcache.xml</prop>-->
<!--<prop key="hibernate.cache.provider_class">${hibernate.cache.region.factory_class}</prop>-->
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
<prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">classpath:ehcache.xml</prop>
<!-- 项目启动时初始化CurrentSessionContext,用于获取session(sessionFactory.getCurrentSession()) -->
<prop key="hibernate.current_session_context_class">${hibernate.current_session_context_class}</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>cn.com.itmy</value>
</list>
</property>
</bean> <!-- 事务管理器 -->
<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"/>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<!-- 开启aop -->
<aop:config proxy-target-class="true"><!-- expose-proxy="true"-->
<aop:pointcut id="txPointcut" expression="execution(* cn.*.*.service..*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/>
</aop:config> <bean class="cn.telemedias.commons.api.commons.context.SystemContext" lazy-init="false"/>
<import resource="classpath:applicationContext-cache.xml"/>
<import resource="classpath:applicationContext-shiro.xml"/>
<import resource="classpath:applicationContext-mq.xml"/>
</beans>

Spring配置数据库连接的更多相关文章

  1. Druid + spring 配置数据库连接池

    1. Druid的简介 Druid是一个数据库连接池.Druid是目前最好的数据库连接池,在功能.性能.扩展性方面,都超过其他数据库连接池,包括DBCP.C3P0.BoneCP.Proxool.JBo ...

  2. Spring配置-数据库连接池proxool[转]

    数据库连接是一种关键的有限的昂贵的资源,这一点在多用户的网页应用程序中体现得尤为突出.对数据库连接的管理能显著影响到整个应用程序的伸缩性和健壮性,影响到程序的性能指标.数据库连接池正是针对这个问题提出 ...

  3. spring配置数据库连接池druid

    连接池原理 连接池基本的思想是在系统初始化的时候,将数据库连接作为对象存储在内存中,当用户需要访问数据库时,并非建立一个新的连接,而是从连接池中取出一个已建立的空闲连接对象.使用完毕后,用户也并非将连 ...

  4. spring配置数据库连接池

    1. jdbcConfig.properties文件中 jdbc.jdbcUrl=jdbc:mysql:///ssm-crudjdbc.driverClass=com.mysql.jdbc.Drive ...

  5. Spring配置连接池

    ---------------------siwuxie095                                 Spring 配置连接池         1.Spring 配置内置连接 ...

  6. Spring配置文件中如何使用外部配置文件配置数据库连接

    直接在spring的配置文件中applicationContext.xml文件中配置数据库连接也可以,但是有个问题,需要在url后带着使用编码集和指定编码集,出现了如下问题,&这个符号报错-- ...

  7. SpringBoot学习(三)-->Spring的Java配置方式之读取外部的资源配置文件并配置数据库连接池

    三.读取外部的资源配置文件并配置数据库连接池 1.读取外部的资源配置文件 通过@PropertySource可以指定读取的配置文件,通过@Value注解获取值,具体用法: @Configuration ...

  8. spring配置详解

    1.前言 公司老项目的后台,均是基于spring框架搭建,其中还用到了log4j.jar等开源架包.在新项目中,则是spring和hibernate框架均有使用,利用了hibernate框架,来实现持 ...

  9. java配置数据库连接池的方法步骤

    java配置数据库连接池的方法步骤 java配置数据库连接池的方法步骤,需要的朋友可以参考一下   先来了解下什么是数据库连接池数据库连接池技术的思想非常简单,将数据库连接作为对象存储在一个Vecto ...

  10. Spring的DataSource配置、将Hibernate配置所有写到Spring配置

    DataSource能够集中管理数据库连接,降低维护工作量,使部署更简单: Spring的DataSource配置:(Spring数据源配置)这里使用dbcp,还有非常多其它的如c3p0,jdbc,j ...

随机推荐

  1. Hex格式和Mot格式简介

    Hex格式和Mot格式简介 一.Hex格式介绍    1.1 什么是 Intel HEX 文件格式?  Intel HEX文件 是由一行行符合 Intel HEX文件格式的文本所构成的ASCII文本文 ...

  2. 循环文件夹汇总所有发票开具Excel文件数据

    'xlsx cnADO.Open "provider=Microsoft.ACE.OLEDB.12.0;extended properties='excel 8.0;hdr=no;imex= ...

  3. ASP.NET在Repeater中使用Button控件报错

    普通Button在这里会报错,小编找了一天也没有解决这个问题, 这里可以换做LinkButton或者ImageButton替换普通的Button

  4. 会长哥哥帮助安装ubuntu

    今晚突然想到要安装虚拟机,因为我原来上的python预科班里面讲解安装虚拟机,但是我当时没有安装上,导致预科班后面的课我没听懂,今天听课讲到字符和编码 所以想到了我的虚拟机,于是今晚很谨慎的求助会长大 ...

  5. element ui 全选反选

    <el-checkbox class="selectAll" :indeterminate="isIndeterminate" v-model=" ...

  6. C# EF框架的入门使用

    如何构建数据模型 新建项 ADO.NET 实体模型 设置链接 链接字符串需要选择"是,包含敏感数据 注意:EF的框架引用的表应该要存在主键,程序引用中要包含 using System.Dat ...

  7. python之tk学习,闲鱼搜索-小记

    (如想转载,请联系博主或贴上本博地址) 编程,逻辑,总是让人如痴如醉. 下面进入正题. 火热的天气配上火热的python,python的入门友好性让门外汉们都看到了希望.当然自己写的程序如果没有GUI ...

  8. cenos7配置epel源

    1.首先进入/etc/yum.repos.d/目录下,新建一个repo_bak目录,用于保存系统中原来的repo文件 [root@bogon ~]# cd /etc/yum.repos.d/ [roo ...

  9. 从babel编译结果分析class的实现原理

    示例: class A { // 属性表达式 prop1 = 1; // get方法 get value() { console.log('Getting the current value!'); ...

  10. windows2003 的安装以及安装时遇到的问题

    windows2003 的安装以及安装时遇到的问题 简介:Windows Server 2003是微软于2003年3月28日发布的基于Windows XP/NT5.1开发的服务器操作系统,并在同年4月 ...