spring基本配置

基本配置

spring基本配置
<?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/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">

    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="configLocation">
            <value>
                classpath:hibernate.cfg.xml
        </value>
        </property>
    </bean>

    <bean id="txManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <aop:config>
        <aop:pointcut expression="execution(public * com.hnct.rpms.service*.*.*(..))"
            id="txAop" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="txAop" />
    </aop:config>

    <tx:advice id="txAdvice" transaction-manager="txManager">
        <tx:attributes>
        <!-- 当调用方法没有transaction时,则创建,有就不需要了 -->
            <tx:method name="*" propagation="REQUIRED" />
        </tx:attributes>
    </tx:advice>

    <bean id="IUserDao" class="com.hnct.rpms.dao.impl.UserDaoImpl">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <bean id="IUserService" class="com.hnct.rpms.service.impl.UserServiceImpl">
        <property name="userDao" ref="IUserDao"></property>
    </bean>
    <bean id="userAction" class="com.hnct.rpms.action.UserAction"
        scope="prototype">
        <property name="userService" ref="IUserService"></property>
        <property name="roleService" ref="IRoleService"></property>
    </bean>
spring基本配置

 

spring基本配置,布布扣,bubuko.com

spring基本配置

上一篇:Struts+HIbernate+Spring


下一篇:C语言之捕捉信号