<?xml version="1.0" encoding="UTF-8"?>
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:aop="http://www.springframework.org/schema/aop"
|
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
|
|
xsi:schemaLocation="
|
http://www.springframework.org/schema/beans
|
http://www.springframework.org/schema/beans/spring-beans.xsd
|
http://www.springframework.org/schema/mvc
|
http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
http://www.springframework.org/schema/jee
|
http://www.springframework.org/schema/jee/spring-jee.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
|
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
|
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/context/spring-context.xsd">
|
|
<!-- 实体管理器 -->
|
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
<property name="dataSource" ref="druidDataSource" />
|
<property name="packagesToScan" value="com.qxueyou.scc" />
|
<property name="persistenceProvider">
|
<bean class="org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider" />
|
</property>
|
|
<property name="jpaVendorAdapter">
|
<bean id="hibernateJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
|
<property name="generateDdl" value="false" />
|
<property name="database" value="MYSQL" />
|
<property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
|
<property name="showSql" value="false" />
|
</bean>
|
</property>
|
|
<property name="jpaDialect">
|
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
|
</property>
|
|
<property name="jpaPropertyMap">
|
<props>
|
<prop key="hibernate.dialect">com.qxueyou.scc.base.handler.QxueyouMysqlDialect</prop>
|
<prop key="hibernate.show_sql">true</prop>
|
<prop key="connection.characterEncoding">GBK</prop>
|
<prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</prop>
|
<prop key="hibernate.physical_naming_strategy">org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy</prop>
|
<prop key="hibernate.cache.use_second_level_cache">false</prop>
|
</props>
|
</property>
|
</bean>
|
|
<!-- 重要配置:启用扫描并自动创建代理的功能 -->
|
<jpa:repositories base-package="com.qxueyou.scc"
|
repository-impl-postfix="Impl"
|
transaction-manager-ref="transactionManager"
|
entity-manager-factory-ref="entityManagerFactory"/>
|
|
<!-- 事务管理器 -->
|
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
|
<property name="entityManagerFactory" ref="entityManagerFactory"/>
|
</bean>
|
|
<!-- 事务 -->
|
<tx:advice id="txAdvice" transaction-manager="transactionManager">
|
<tx:attributes>
|
<tx:method name="add*" propagation="REQUIRED" />
|
<tx:method name="insert*" propagation="REQUIRED" />
|
<tx:method name="save*" propagation="REQUIRED" />
|
<tx:method name="update*" propagation="REQUIRED" />
|
<tx:method name="delete*" propagation="REQUIRED" />
|
<tx:method name="do*" propagation="REQUIRED" />
|
<tx:method name="execute*" propagation="REQUIRED" />
|
<tx:method name="logSave*" propagation="REQUIRES_NEW" />
|
<!-- <tx:method name="*" read-only="true" />-->
|
<tx:method name="*" read-only="false" />
|
</tx:attributes>
|
</tx:advice>
|
|
<!-- 事务入口 -->
|
<aop:config>
|
<aop:pointcut id="allServiceMethod" expression="execution(* com.qxueyou.scc..*Service.*(..))" />
|
<aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethod" />
|
</aop:config>
|
|
|
</beans>
|