zoukankan      html  css  js  c++  java
  • applicationContext.xml

    <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:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"

    xsi:schemaLocation="http://www.springframework.org/schema/beans

             http://www.springframework.org/schema/beans/spring-beans.xsd

             http://www.springframework.org/schema/context

             http://www.springframework.org/schema/context/spring-context.xsd

             http://www.springframework.org/schema/tx

             http://www.springframework.org/schema/tx/spring-tx.xsd

             http://www.springframework.org/schema/aop

             http://www.springframework.org/schema/aop/spring-aop.xsd">

    <context:annotation-config />

    <!-- 扫描com.liuruichao包下得所有类 -->

    <context:component-scan base-package="com.liuruichao" />


    <bean id="dataSource"class="org.apache.commons.dbcp.BasicDataSource"

    destroy-method="close">

    <property name="driverClassName"value="${jdbc.driverClassName}" />

    <property name="url" value="${jdbc.url}" />

    <property name="username" value="${jdbc.username}" />

    <property name="password" value="${jdbc.password}" />

    </bean>

    <context:property-placeholder location="classpath:jdbc.properties" />


    <bean id="sessionFactory"

    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">

    <property name="dataSource" ref="dataSource" />

    <property name="packagesToScan">

    <list>

    <value>com.liuruichao.model</value>

    </list>

    </property>

    <property name="hibernateProperties">

    <value>

    hibernate.dialect=org.hibernate.dialect.MySQLDialect

    hibernate.show_sql=true

    hibernate.format_sql=true

    hibernate.hbm2ddl.auto=update

    </value>


    </property>

    </bean>


    <bean id="transactionManager"

    class="org.springframework.orm.hibernate4.HibernateTransactionManager">

    <property name="sessionFactory" ref="sessionFactory" />

    </bean>


    <tx:annotation-driven transaction-manager="transactionManager" />


    <aop:config>

    <!--定义需要进行切面编程的所有方法,定义成为一个id是nicai的bean 代表了多有的方法 -->

    <aop:pointcut id="bussinessService"

    expression="execution (public * com.liuruichao.service.*.*(..))" />

    <!-- id是txAdvice的bean 切入 id是nicai的所有方法 把他们俩整合到一起 -->

    <aop:advisor advice-ref="txAdvice" pointcut-ref="bussinessService"/>

    </aop:config>

    <!-- 定义一个指导意见(在某些方法执行前执行)提高效率的 代表了所要加入的切面 -->

    <tx:advice id="txAdvice" transaction-manager="transactionManager">

    <tx:attributes>

    <tx:method name="save*" propagation="REQUIRED" />

    <tx:method name="add*" propagation="REQUIRED" />

    <tx:method name="update*" propagation="REQUIRED" />

    <tx:method name="delete*" propagation="REQUIRED" />

    <tx:method name="find*" read-only="true" />

    <tx:method name="load*" read-only="true" />

    </tx:attributes>

    </tx:advice>

    </beans>

  • 相关阅读:
    Python之文件操作
    document.hasFocus() & $(window).blur()
    innerHtml 会忽略里面元素的属性
    ng  命令集合
    阿里云ECS CentOs7.3下搭建LAMP环境(Apache2.4 + Mysql5.7 + PHP5.6 + Laravel5.2)
    在忘记root密码的时候,可以这样 亲测可用
    下一次装mysql 试一下这个方法
    CentOS-6.8安装Mysql-5.5.29
    阿里云服务器下安装LAMP环境(CentOS Linux 6.3)
    CentOS 7.2 配置Apache服务(httpd)--上篇
  • 原文地址:https://www.cnblogs.com/liuruichao/p/4005881.html
Copyright © 2011-2022 走看看