jap集成

<?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:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
	
	<context:property-placeholder location="classpath:database.properties" ignore-unresolvable="true" />
	
	<!-- dataSource:用于指定Spring定义的数据源; -->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
		<property name="driverClass" value="${jdbc.driverClass}" />
		<property name="jdbcUrl" value="${jdbc.jdbcUrl}" />
		<property name="user" value="${jdbc.user}" />
		<property name="password" value="${jdbc.password}" />
		<property name="minPoolSize" value="${jdbc.minPoolSize}"></property>
		<property name="maxPoolSize" value="${jdbc.maxPoolSize}"></property>
		<property name="initialPoolSize" value="${jdbc.initialPoolSize}"></property>
		<property name="acquireIncrement" value="${jdbc.acquireIncrement}"></property>
		<property name="maxIdleTime" value="${jdbc.maxIdleTime}"></property>
	</bean>
	
	
	
	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
		<property name="entityManagerFactory" ref="entityManagerFactory" />
	</bean>
	
	<tx:annotation-driven transaction-manager="transactionManager" />
	
	<!-- LocalContainerEntityManagerFactoryBean:适用于所有环境的FactoryBean,能全面控制EntityManagerFactory配置
	,如指定Spring定义的DataSource等等。 
	LocalContainerEntityManagerFactoryBean:指定使用本地容器管理EntityManagerFactory,从而进行细粒度控制;
	
	-->
	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="persistenceProviderClass" value="org.hibernate.ejb.HibernatePersistence"></property>
		<!-- dataSource属性指定使用Spring定义的数据源;		 -->
		<property name="dataSource" ref="dataSource" />
		<!-- loadTimeWeaver:用于指定LoadTimeWeaver实现,从而允许JPA 加载时修改相应的类文件。
		具体使用得参考相应的JPA规范实现厂商文档,如Hibernate就不需要指定loadTimeWeaver。
		 -->
		<property name="loadTimeWeaver">
			<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
		</property>  
		<property name="packagesToScan">
			<list>
				<value>com.boventech.learning.entity</value>
			</list>
		</property>
		<!-- jpaProperties:此处指定“hibernate.show_sql =true”表示在日志系统debug级别下将打印所有生成的SQL。 -->
		<property name="jpaProperties">
	        <props>
	            <prop key="hibernate.dialect">${jdbc.dialect}</prop>
	            <!--  <prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>-->
	            <prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
	            <prop key="hibernate.show_sql">${jpa.showSql}</prop>
	            <prop key="hibernate.format_sql">${jpa.formatSql}</prop>
	            <prop key="hibernate.hbm2ddl.auto">${jpa.hbm2ddl.auto}</prop>
	        </props>
	    </property>
	</bean>

	<!-- JPA annotations bean post processor -->
	<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

</beans>



你可能感兴趣的:(jap集成)