spring 配置文件

来源:互联网 发布:python爬虫赚钱收入 编辑:程序博客网 时间:2024/04/30 23:01

<?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: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.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

<!--数据源datasource的声明-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></property>
<property name="url"><value>jdbc:oracle:thin:@192.168.7.248:1521:accp</value></property>
<property name="username"><value>crm</value></property>
<property name="password"><value>crm</value></property>
</bean>

<!--Session Factory声明-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>com/crm/customer/entity/Customerinfo.hbm.xml</value>
<value>com/crm/customer/entity/Customertrack.hbm.xml</value>
<value>com/crm/customer/entity/Probleminfo.hbm.xml</value>
<value>com/crm/customer/entity/Sendinform.hbm.xml</value>
<value>com/crm/customer/entity/Serviceinfo.hbm.xml</value>
<value>com/crm/customer/entity/Customerdev.hbm.xml</value>

<value>com/crm/scheme/entity/Product.hbm.xml</value>
<value>com/crm/scheme/entity/Provide.hbm.xml</value>
<value>com/crm/scheme/entity/Salescheme.hbm.xml</value>

<value>com/crm/system/entity/Userinfo.hbm.xml</value>
<value>com/crm/system/entity/Cityinfo.hbm.xml</value>
<value>com/crm/system/entity/Tradeinfo.hbm.xml</value>

<value>com/crm/vendition/entity/Chance.hbm.xml</value>
<value>com/crm/vendition/entity/Chancedetail.hbm.xml</value>
<value>com/crm/vendition/entity/Orderitems.hbm.xml</value>
<value>com/crm/vendition/entity/Orders.hbm.xml</value>
<value>com/crm/vendition/entity/Ordertrack.hbm.xml</value>
<value>com/crm/vendition/entity/Sourceinfo.hbm.xml</value>
<value>com/crm/vendition/entity/Trackdetail.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>

<!-- hibernate 事务-->
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>

<!-- baseDAO层-->
<bean id="basedao" class="com.crm.dao.BaseDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

<!-- 定义一个事务拦截器 -->
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="*" />
</tx:attributes>
</tx:advice>

  <!--定义customer模块的service切入 -->
    <aop:config>
<aop:pointcut id="customerPoint"
expression="execution(* com.crm.customer.service..*.*(..))" />
<aop:advisor advice-ref="txAdvice"
pointcut-ref="customerPoint" />
</aop:config>

  <!--定义scheme模块的service切入 -->
    <aop:config>
<aop:pointcut id="schemePoint"
expression="execution(* com.crm.scheme.service..*.*(..))" />
<aop:advisor advice-ref="txAdvice"
pointcut-ref="schemePoint" />
</aop:config>

<!--定义system模块的service切入 -->
    <aop:config>
<aop:pointcut id="systemPoint"
expression="execution(* com.crm.system.service..*.*(..))" />
<aop:advisor advice-ref="txAdvice"
pointcut-ref="systemPoint" />
</aop:config>

  <!--定义vendition模块的service切入 -->
    <aop:config>
<aop:pointcut id="venditionPoint"
expression="execution(* com.crm.vendition.service..*.*(..))" />
<aop:advisor advice-ref="txAdvice"
pointcut-ref="venditionPoint" />
</aop:config>

<!-- 定义一个baseservice -->

<bean id="baseService" class="com.crm.service.BaseService">
<property name="basedao">
<ref bean="basedao"/>
</property>
</bean>
</beans>

原创粉丝点击