applicationContext.xml
发布时间:2020-12-16 00:35:50 所属栏目:百科 来源:网络整理
导读:?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:util="http://www.springframework.org/schema/util"xmlns:p="http://www.springframework.or
<?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:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <!-- 导入配置文件 --> <context:property-placeholder location="classpath:jdbc.properties" /> <!-- 数据源 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <!-- 设置JDBC驱动名称 --> <property name="driverClass" value="${jdbc.driver}" /> <!-- 设置JDBC连接URL --> <property name="jdbcUrl" value="${jdbc.url}" /> <!-- 设置数据库用户名 --> <property name="user" value="${jdbc.username}" /> <!-- 设置数据库密码 --> <property name="password" value="${jdbc.password}" /> <!-- 设置连接池初始值 --> <property name="initialPoolSize" value="5" /> <!-- 设置连接池最大值 --> <property name="maxPoolSize" value="30" /> <!-- 设置连接池最小空闲值 --> <property name="minPoolSize" value="5" /> <!-- 每次增长的连接数 --> <property name="acquireIncrement" value="3" /> <!-- 等待获取新连接的时间 --> <property name="checkoutTimeout" value="30000" /> <!-- 每60秒检查每个连接的状态 --> <property name="idleConnectionTestPeriod" value="60000" /> <!-- 超时等待时间以毫秒为单位 --> <property name="maxIdleTime" value="180000" /> </bean> <!-- 配置sessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!-- 数据源 --> <property name="dataSource" ref="dataSource" /> <!-- hibernate的属性配置 --> <property name="hibernateProperties"> <value> <!-- 设置数据库方言 --> hibernate.dialect=${hibernate.dialect} <!-- 输出SQL语句到控制台 --> hibernate.show_sql=${hibernate.show_sql} <!-- 格式化输出到控制台的SQL语句 --> hibernate.format_sql=${hibernate.format_sql} <!-- 是否开启二级缓存 --> hibernate.cache.use_second_level_cache=true <!-- 配置二级缓存产品 --> hibernate.cache.provider_class=org.hibernate.cache.OSCacheProvider <!-- 是否开启查询缓存 --> hibernate.cache.use_query_cache=false <!-- 数据库批量查询数 --> hibernate.jdbc.fetch_size=100 <!-- 数据库批量更新数 --> hibernate.jdbc.batch_size=50 </value> </property> <!-- hibernate的映射文件路径 --> <property name="configLocation" value="classpath:hibernate.cfg.xml"> </property> </bean> <!-- 使用注解注册机 --> <context:component-scan base-package="com.hwt"></context:component-scan> <!-- 事务配置 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <tx:advice id="tx" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="get*" propagation="NOT_SUPPORTED"/> <tx:method name="load*" propagation="NOT_SUPPORTED"/> <tx:method name="find*" propagation="NOT_SUPPORTED" /> <tx:method name="*" propagation="NOT_SUPPORTED"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="pt" expression="execution(* com.hwt.service..*.*(..))"/> <aop:advisor advice-ref="tx" pointcut-ref="pt"/> </aop:config> </beans> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |