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

    <?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.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx.xsd">
    
    <!-- 开启注解的扫描 -->
    <context:component-scan base-package="com.itheima"/>
    
    <!-- 配置C3P0的连接池 -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="driverClass" value="com.mysql.jdbc.Driver"/>
    <property name="jdbcUrl" value="jdbc:mysql:///day68"/>
    <property name="user" value="root"/>
    <property name="password" value="root"/>
    </bean>
    
    <!-- Spring整合hibernate框架 -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
    <!-- 注入连接池 -->
    <property name="dataSource" ref="dataSource"/>
    <!-- 注入属性 -->
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.format_sql">true</prop>
    <prop key="hibernate.hbm2ddl.auto">none</prop>
    <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate5.SpringSessionContext</prop>
    </props>
    </property>
    <!-- 注入扫描entity注解 -->
    <property name="packagesToScan">
    <array>
    <value>com</value>
    </array>
    </property>
    </bean>
    
    <!-- 先配置模板 -->
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
    <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    
    <!-- 配置事务 -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    
    <!-- 配置事务通知 -->
    <tx:advice id="myAdvice" transaction-manager="transactionManager">
    <tx:attributes>
    <!-- <tx:method name="save*" isolation="DEFAULT" propagation="REQUIRED"/>
    <tx:method name="update*" isolation="DEFAULT" propagation="REQUIRED"/>
    <tx:method name="delete*" isolation="DEFAULT" propagation="REQUIRED"/>
    <tx:method name="find*" read-only="true"/> -->
    <tx:method name="*" isolation="DEFAULT" propagation="REQUIRED"/>
    </tx:attributes>
    </tx:advice>
    
    <!-- 配置AOP增强 -->
    <aop:config>
    <aop:advisor advice-ref="myAdvice" pointcut="execution(* com.itheima.*.service.*ServiceImpl.*(..))"/>
    </aop:config>
    </beans>
    
     
  • 相关阅读:
    css小技巧: select的css控制
    js中不存在exit函数,程序的运行中断停止,可使用return
    转载: WebCore渲染之一:基础
    转载: WEB架构师成长系列索引
    js:<form></form>中有<a>按钮时不能跳转?
    小心得:前台与后台的数据传递
    php session和cookie使用说明
    css 字体使用
    转载: PHP引用(&)使用详解
    三层架构下的增删改查 荣
  • 原文地址:https://www.cnblogs.com/qiqimu/p/7677850.html
Copyright © 2011-2022 走看看