Конфигурация Hikari в xml для источников данных Master/Slave

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

Кроме того, как мне создать новую фабрику менеджера сущностей в том же самом?

Мой 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 для добавления ведомого источника данных?


person The-Proton-Resurgence    schedule 20.09.2016    source источник


Ответы (1)


укажите URL, как описано в документация mysql-connector-j

person Nitin    schedule 23.09.2016