2016-09-20 1 views
0

В настоящее время у меня есть источник данных, настроенный с использованием Hikari в моем applicationContext.xml. Я хочу настроить в том же файле xml для источника данных типа master/slave.Конфигурация Hikari в xml для основных/ведомых источников данных

Также как установить новую фабрику управления сущностями в том же самом?

Моего applicationContext.xml, который настроен на 1 источник данных (читаются как мастер) выглядит следующим образом:

<xml version="1.0" encoding="UTF-8" standalone="no"?> 
    <beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task" 
     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc" 
     xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.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-3.2.xsd 
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd 
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd 
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd 
      http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"> 

     <context:property-placeholder location="classpath*:META-INF/spring/*.properties" /> 

     <context:spring-configured /> 


     <context:component-scan base-package="com.lkart.dao"> 
     </context:component-scan> 

    <bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" 
      destroy-method="close"> 
      <property name="dataSourceClassName" value="${database.driverClassName}" /> 
      <property name="maximumPoolSize" value="10" /> 
      <property name="maxLifetime" value="1800000" /> 
      <property name="idleTimeout" value="600000" /> 
      <property name="connectionTimeout" value="60000" /> 
      <property name="dataSourceProperties"> 
       <props> 
        <prop key="url">${database.url}</prop> 
        <prop key="user">${database.username}</prop> 
        <prop key="password">${database.password}</prop> 
        <prop key="prepStmtCacheSize">250</prop> 
        <prop key="prepStmtCacheSqlLimit">2048</prop> 
        <prop key="cachePrepStmts">true</prop> 
        <prop key="useServerPrepStmts">true</prop> 
       </props> 
      </property> 
     </bean> 

     <bean 
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" 
      id="entityManagerFactory"> 
      <property name="persistenceXmlLocation" value="classpath*:META-INF/persistence.xml" /> 
      <property name="persistenceUnitName" value="persistenceUnit" /> 
      <property name="dataSource" ref="dataSource" /> 
     </bean> 

     <bean class="org.springframework.orm.jpa.JpaTransactionManager" 
      id="transactionManager"> 
      <property name="entityManagerFactory" ref="entityManagerFactory" /> 
     </bean> 

    <tx:annotation-driven transaction-manager="transactionManager" /> 

</beans> 

Как настроить этот XML для добавления подчиненного источника данных?

ответ

Смежные вопросы