<?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" xmlns:jpa="http://www.springframework.org/schema/data/jpa" "> <context:component-scan base-package="cn.javass"> <context:exclude-filter type="annotation“ expression="org.springframework.stereotype.Controller"/> </context:component-scan> <aop:aspectj-autoproxy proxy-target-class="true"/> <!-- 开启注解事务 只对当前配置文件有效 --> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/> <jpa:repositories base-package="cn.javass" repository-impl-postfix="Impl" entity-manager-factory-ref="entityManagerFactory" transaction-manager-ref="transactionManager"> </jpa:repositories> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="packagesToScan" value="cn.javass"/> <property name="persistenceProvider"> <bean class="org.hibernate.ejb.HibernatePersistence"/> </property> <property name="jpaVendorAdapter"> <bean 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="true"/> </bean> </property> <property name="jpaDialect"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/> </property> <property name="jpaPropertyMap"> <map> <entry key="hibernate.query.substitutions" value="true 1, false 0"/> <entry key="hibernate.default_batch_fetch_size" value="16"/> <entry key="hibernate.max_fetch_depth" value="2"/> <entry key="hibernate.generate_statistics" value="true"/> <entry key="hibernate.bytecode.use_reflection_optimizer" value="true"/> <entry key="hibernate.cache.use_second_level_cache" value="false"/> <entry key="hibernate.cache.use_query_cache" value="false"/> </map> </property> </bean> <!--事务管理器配置--> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <bean name="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName"><value>org.gjt.mm.mysql.Driver</value></property> <property name="url"><value>jdbc:mysql://localhost:3306/cc?useUnicode=true&characterEncoding=UTF-8</value></property> <property name="username"> <value>root</value> </property> <property name="password" value="cc"/> </bean> </beans> |