qq_16863313 2017-07-23 05:18 采纳率: 0%
浏览 727

求大神,求大神,求大神,求大神,spring配置多租户错误,去掉多租户配置不报错。

7-23 13:04:58,761 ERROR DriverManagerConnectionProviderImpl - HHH000152: JDBC URL was not specified by property hibernate.connection.url
07-23 13:04:58,801 ERROR ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: HHH000152: JDBC URL was not specified by property hibernate.connection.url
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:684)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)

--------------------文件配置去掉多租户配置不报错

<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close">
    <property name="driverClass">
        <value>oracle.jdbc.driver.OracleDriver</value>
    </property>

    <property name="jdbcUrl">
        <value>jdbc:oracle:thin:@localhost:1521:myoracle</value>
    </property>
    <property name="user">
        <value>shulizhi</value>
    </property>
    <property name="password">
        <value>shulizhi</value>
    </property>

    <!--
    连接池中保留的最小连接数。-->
    <property name="minPoolSize">
        <value>5</value>
    </property>

    <!--连接池中保留的最大连接数。Default: 15 -->
    <property name="maxPoolSize">
        <value>50</value>
    </property>

    <!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
    <property name="initialPoolSize">
        <value>5</value>
    </property>

    <!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
    <property name="maxIdleTime">
        <value>30</value>
    </property>

    <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
    <property name="acquireIncrement">
        <value>5</value>
    </property>

    <!--
        JDBC的标准参数,用以控制数据源内加载的PreparedStatements数量。但由于预缓存的statements
        属于单个connection而不是整个连接池。所以设置这个参数需要考虑到多方面的因素。
        如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0
        <property name="maxStatements"> <value>0</value> </property>
    -->
    <property name="maxStatements">
        <value>0</value>
    </property>
    <property name="maxStatementsPerConnection">
        <value>100</value>
    </property>

    <!--每60秒检查所有连接池中的空闲连接。Default: 0 -->
    <property name="idleConnectionTestPeriod">
        <value>60</value>
    </property>

    <!--定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 -->
    <property name="acquireRetryAttempts">
        <value>30</value>
    </property>

    <!--
        获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常。但是数据源仍有效
        保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试
        获取连接失败后该数据源将申明已断开并永久关闭。Default: false
    -->
    <property name="breakAfterAcquireFailure">
        <value>false</value>
    </property>

    <!--
        因性能消耗大请只在需要的时候使用它。如果设为true那么在每个connection提交的
        时候都将校验其有效性。建议使用idleConnectionTestPeriod或automaticTestTable
        等方法来提升连接测试的性能。Default: false <property
        name="testConnectionOnCheckout"> <value>false</value> </property>
    -->
</bean>

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource">
        <ref bean="dataSource" />
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.generate_statistics">true</prop>
            <prop key="hibernate.connection.release_mode">auto</prop>
            <prop key="hibernate.autoReconnect">true</prop>
            <prop key="hibernate.jdbc.batch_size">30</prop>             
            <prop key="hibernate.multiTenancy">SCHEMA</prop>
            <prop key="hibernate.tenant_identifier_resolver">hotel.dao.hibernate.TenantIdResolver</prop>
            <prop key="hibernate.multi_tenant_connection_provider">hotel.dao.hibernate.SchemaBasedMultiTenantConnectionProvider</prop>

        </props>
    </property>
    <property name="mappingDirectoryLocations">
        <list>
              <value>classpath:com/buddha/domain/</value>
        </list>
    </property>
</bean>
<bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>
<context:annotation-config />
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    <property name="dataSource">
        <ref bean="dataSource" />
    </property>
</bean>

  • 写回答

1条回答 默认 最新

  • devmiao 2017-07-23 14:44
    关注
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?