<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>