<?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"> <context:component-scan base-package="com.beecode.inz.contract"></context:component-scan> <!-- 数据库映射 --> <bean id="defaultDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.default.driverClassName}" /> <property name="url" value="${jdbc.default.url}" /> <property name="username" value="${jdbc.default.user}" /> <property name="password" value="${jdbc.default.pass}" /> </bean> <bean id="mutitenancyDataSourceBasicConfiguration" class="com.beecode.amino.tenant.DataSourceConfiguration"> <property name="driverClassName" value="${jdbc.mutitenancy.driverClassName}" /> <property name="url" value="${jdbc.mutitenancy.url}" /> <property name="username" value="${jdbc.mutitenancy.user}" /> <property name="password" value="${jdbc.mutitenancy.pass}" /> <property name="properties"> <props> <prop key="useSSL">true</prop> <prop key="c3p0.minPoolSize">${c3p0.minPoolSize}</prop> <prop key="c3p0.maxPoolSize">${c3p0.maxPoolSize}</prop> <prop key="c3p0.maxIdleTime">${c3p0.maxIdleTime}</prop> <prop key="c3p0.maxStatements">${c3p0.maxStatements}</prop> <prop key="c3p0.idleTestPeriod">${c3p0.idleTestPeriod}</prop> <prop key="c3p0.acquireIncrement">${c3p0.acquireIncrement}</prop> </props> </property> </bean> <bean id="tenantDataSourceLookup" class="com.beecode.amino.tenant.support.DefaultTenantDataSourceLookup"> <property name="basicConfiguration" ref="mutitenancyDataSourceBasicConfiguration" /> </bean> <bean id="currentTenantIdentifierResolver" class="com.beecode.amino.tenant.hibernate.DefaultCurrentTenantIdentifierResolver" /> <bean id="multiTenantConnectionProvider" class="com.beecode.amino.tenant.hibernate.LookupBasedMultiTenantConnectionProvider"> <property name="defaultDataSource" ref="defaultDataSource" /> </bean> <bean id="sessionFactory" class="com.beecode.bcp.store.hibernate.HibernateSessionFactoryBean" scope="metadata" lazy-init="true"> <property name="currentTenantIdentifierResolver" ref="currentTenantIdentifierResolver" /> <property name="multiTenantConnectionProvider" ref="multiTenantConnectionProvider" /> <property name="mappingLocations"> <list> <value>classpath*:/config/*.hbm.xml</value> <value>classpath*:/config/hbm/*.xml</value> <value>classpath*:config/quartz/hbm/*.xml</value> </list> </property> <property name="packagesToScan"> <list> <value>com.beecode.inz.authmgr.entity</value> <value>com.beecode.bap.scheduler.entity</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> <prop key="hibernate.multiTenancy">${hibernate.multiTenancy}</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>