persistence.xml 3.28 KB
Newer Older
PWF-WK01\pengwufeng committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
<?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:tx="http://www.springframework.org/schema/tx"
  xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
  xmlns:util="http://www.springframework.org/schema/util" xmlns:jee="http://www.springframework.org/schema/jee"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
    	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
    	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd
		http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd">

	<!-- 数据库映射 -->
	<bean id="dataSource"
		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		
	<!-- 	<property name="driverClassName" value="${jdbc.driverClassName}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.user}" />
		<property name="password" value="${jdbc.pass}" /> -->
		
	
		<!-- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
		<property name="url" value="jdbc:mysql://10.2.9.114:3306/test" />
		<property name="username" value="root" />
		<property name="password" value="root" /> -->
		
		<property name="driverClassName" value="com.mysql.jdbc.Driver" />
		<property name="url" value="jdbc:mysql://127.0.0.1:3306/base?useUnicode=true&amp;characterEncoding=UTF-8" />
		<property name="username" value="root" />
		<property name="password" value="root" />
	</bean>


	<bean id="sessionFactory"
		class="com.beecode.bcp.store.hibernate.HibernateSessionFactoryBean"
		scope="metadata" lazy-init="true">
		<property name="dataSource" ref="dataSource" />
		<property name="mappingLocations">
			<list>
				<value>classpath*:config/*.hbm.xml</value>
			</list>
		</property>
		<property name="packagesToScan">
			<list>
				<value>com.beecode.amino.test.war.entity</value>
				<value>com.beecode.inz.authmgr.**.*</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
				<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
			</props>
		</property>
	</bean>

	<!-- 配置Hibernate事务管理器 -->
	<bean id="transactionManager"
		class="com.beecode.bcp.store.hibernate.HibernateTransactionManager">
		<property name="sessionFactoryName" value="sessionFactory" />
	</bean>

	<!-- 配置Hibernate模板 -->
	<bean id="hibernateOperations"
		class="com.beecode.bcp.store.hibernate.HibernateTemplate">
		<property name="sessionFactoryName" value="sessionFactory" />
	</bean>

	<!-- 配置事务异常封装 -->
	<bean id="persistenceExceptionTranslationPostProcessor"
		class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />

</beans>