2013-07-16 275 views
0

配置我的數據源:初始大小的BasicDataSource

<bean id ="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> 
    <property name="driverClassName" value="org.hsqldb.jdbcDriver"/> 
    <property name="url" value="jdbc:mysql:openshifturl"/> 
    <property name="username" value="username"/> 
    <property name="password" value="pass"/> 
    <property name="maxActive" value="10"/> 
    <property name="initialSize" value="5"/> 
</bean> 

並且得到錯誤:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [EntityOperatorBean.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'initialSize' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'initialSize' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 

當我刪除I​​NITIALSIZE財產都成爲被確定。爲什麼我會遇到這個問題?

+1

您使用的是哪種版本的DBCP?在1.2中增加了'initialSize'。 –

+0

我使用的是1.4版本 –

+0

\t \t \t 公地DBCP \t \t \t 公地DBCP \t \t \t 1.4 \t \t

回答

0

Pavel讓我明白,我的Tomcat服務器對dbcp 1.2具有奇怪的依賴關係。這可能是因爲一開始我創建了對dbcp 1.2的依賴關係。當我將後來的依賴添加到1.4時,它不起作用。

我通過刪除當前的Tomcat服務器並創建新的服務器來解決這個問題。只是激進的方法,但我解決了我的問題。