SSH数据源+注解+事务
来源:互联网 发布:光盘刻录软件哪个好 编辑:程序博客网 时间:2024/05/01 23:58
<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/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
">
<!-- 将加注解的包名全写下来,也可以直接一个*就哦了 -->
<context:component-scan
base-package="org.accp.myspace.dao,org.accp.myspace.biz.impl,org.accp.myspace.web.action" />
<!-- oracle数据源 -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
<property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl"></property>
<property name="username" value="jiang"></property>
<property name="password" value="jiang"></property>
</bean>
<!-- mySQL数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.DriverManagerDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/jboa"></property>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
</bean>
<!-- sqlserver数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.DriverManagerDataSource">
<property name="driverClass" value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
</property>
<property name="jdbcUrl"
value="jdbc:sqlserver://localhost:1433;DatabaseName=jb_crm_team0">
</property>
<property name="user" value="sa"></property>
<property name="password" value="123456"></property>
</bean>
<!-- 配置SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 导入数据源 -->
<property name="dataSource" ref="dataSource"></property>
<!-- 配置参数 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<!-- 实体类包 -->
<property name="mappingDirectoryLocations" value="classpath:/org/accp/myspace/model" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>org.crm.entities.SysRoleRight</value>
</list>
</property>
</bean>
<!-- 配置HibernateTemplate -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 事务配置 -->
<bean class="org.springframework.orm.hibernate3.HibernateTransactionManager"
name="transactionManager">
<!--事务管理器需要知道SessionFactory,以便获得Session操纵事务 -->
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- 配置事务传递属性 -->
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="searth*" read-only="true" />
<tx:method name="query*" read-only="true" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="do*" propagation="REQUIRED"/>
<tx:method name="trade" propagation="REQUIRES_NEW" />
<tx:method name="*" propagation="REQUIRED" read-only="true" />
</tx:attributes>
</tx:advice>
<aop:config>
<!-- 切入点 -->
<!-- 定义哪些方法应用这些规则 -->
<aop:pointcut id="myPointCut"
expression="execution(* org.accp.myspace.biz.impl.*.*(..))" />
<!-- 将事务通知与应用规则的方法组合 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="myPointCut" />
</aop:config>
</beans>
- SSH数据源+注解+事务
- Transaction事务注解和DynamicDataSource动态数据源切换问题解决
- SSH中事务配置详解(全注解)
- $Proxy5 cannot be cast to -- SSH 事务采用java5注解
- SSH与SSM学习之Spring23——Spring事务之注解配置方式管理事务
- 关于spring3.0 后的 事务注解管理指定数据源问题
- 事务注解
- 【Spring】spring-mvc hibernate druid jdbc等数据源事务配置详解(解决注解事务不生效问题)
- ssh事务
- ssh 事务
- 事务管理器和数据源
- sping 配置数据源、事务。
- SSH数据源配置
- SSH数据源配置大全
- SSH配置动态数据源
- SSH C3P0数据源
- spring 管理的事务。个人理解(SSH项目注解配置)
- SSH整合遇到的问题:$Proxy5 cannot be cast to -- SSH 事务采用注解无法获取Service实例bean
- 正则表达式的详细使用帮助
- inotify -- Linux 2.6 内核中的文件系统变化通知机制
- Python实现BBS自动登录并发帖
- sicily 1195. Summation
- 重温c++ hello,world
- SSH数据源+注解+事务
- apache配置,php中没有php5apache2_2.dll的原因及解决办法
- 浅谈Struts2拦截器的原理与实现
- 开启Ubuntu的NAT网络共享(封包转发方式局域网内共享上网)
- 图片加载成功后显示图片
- Null value was assigned to a property of primitive type setter问题分析与解决
- spring+ibatis+mysql简单搭建
- C/C++位操作技巧 【转载】
- ORA-01658 无法为表空间XXX中的段创建INITIAL