首页 > 编程语言 > 详细

spring基本配置

时间:2014-05-25 20:04:51      阅读:330      评论:0      收藏:0      [点我收藏+]

基本配置

bubuko.com,布布扣
<?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>
bubuko.com,布布扣

 

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

spring基本配置

原文:http://www.cnblogs.com/mattzhang/p/3750404.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!