• 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>
    
     
  • 相关阅读:
    WPF Prism8.x源码解析-IDialogService
    .NET 中的正则表达式最佳做法(官方转载)
    .NET 5 中操作注册表方法
    在 .NET 5 及更高版本中比较字符串时的行为更改(官方转载)
    有关比较 .NET 中字符串的最佳做法(官方转载)
    C#创建Windows服务
    [log4j]log4j简单配置
    python基础知识之字符编码与转换
    python基础知识之集合
    python基础知识之字典的操作
  • 原文地址:https://www.cnblogs.com/qiqimu/p/7677850.html
Copyright © 2020-2023  润新知