2016-02-07 53 views
0

我試着將webapp的連接池從c3p0改爲hikaricp。hibernate hikaricp datasource

這裏是我的配置。

<bean id="dataSource" 
    class="org.hibernate.hikaricp.internal.HikariCPConnectionProvider"> 

    <property name="dataSourceClassName" value="${hikari.dataSourceClassName}" /> 
    <property name="maximumPoolSize" value="${hikari.maximumPoolSize}" /> 
    <property name="maxLifetime" value="${hikari.maxLifetime}" /> 
    <property name="idleTimeout" value="${hikari.idleTimeout}" /> 

    <property name="dataSourceProperties"> 
     <props> 
      <prop key="url">${jdbc.url}</prop> 
      <prop key="user">${jdbc.username}</prop> 
      <prop key="password">${jdbc.password}</prop> 
     </props> 
    </property> 
</bean> 

我收到錯誤。

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'dataSourceClassName' of bean class [org.hibernate.hikaricp.internal.HikariCPConnectionProvider]: Bean property 'dataSourceClassName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 
    at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:231) 
    at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:423) 
    at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:280) 
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95) 
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1514) 
    ... 32 more 

在此先感謝您的幫助。

回答

1

org.hibernate.hikaricp.internal.HikariCPConnectionProvider不是javax.sql.DataSource。這是Hibernate的內部組件。

更改配置以使用com.zaxxer.hikari.HikariDataSource代替org.hibernate.hikaricp.internal.HikariCPConnectionProvider

+0

謝謝你這麼多。沒有看到。 – pat3ck029

相關問題