首页 技术 正文
技术 2022年11月21日
0 收藏 505 点赞 3,899 浏览 2743 个字
 <?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-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.xsd" >
<!-- 打开注解注入 -->
<context:annotation-config/>
<context:component-scan base-package="com.hkwy" />
<!-- 添加AOP annotation支持 -->
<aop:aspectj-autoproxy/>
<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<!-- 基本参数 -->
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/spring1"></property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
<!--配置连接池的参数 -->
<property name="initialSize" value="1"></property>
<!-- 连接池的最大数量 -->
<property name="maxActive" value="500"></property>
<!-- 空闲时 连接数降低到最小值 -->
<property name="maxIdle" value="2"></property>
<!-- 空闲时连接池的最小值 -->
<property name="minIdle" value="1"></property>
<!-- 最大等待时间 -->
<property name="maxWait" value="1000"></property>
</bean>
<!--配置hibernate SessionFactory annotation方式 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<!-- 将数据源配置进来 -->
<property name="dataSource" ref="dataSource"></property>
<!--对应的实体类,只需要指定包 -->
<property name="packagesToScan">
<value>com.hkwy.entity</value>
</property>
<!-- 配置hibernate其他参数 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<!--将hibernate交给Spring管理其事务 -->
<!--配置事务管理器 -->
<bean id="txmanager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!--配置Spring的AOP 来管理事务 -->
<aop:config>
<!-- 配置需要管理的dao -->
<aop:pointcut expression="execution (* com.hkwy.dao.*.*(..))" id="aoph"/>
<!--通过advisor来确定具体要加入事务控制的方法 -->
<aop:advisor advice-ref="txadvice" pointcut-ref="aoph"/>
</aop:config>
<!-- 配置advice 来确定哪些数据操作需要加入到事务控制 -->
<tx:advice id="txadvice" transaction-manager="txmanager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice> </beans>
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,954
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,479
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,291
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,108
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,740
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,774