初始大小BasicDataSource

时间:2013-07-16 18:52:25

标签: spring tomcat spring-mvc

我配置了我的dataSource:

 <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?

当我删除initialSize属性时,一切都变好了。为什么我会遇到这个问题?

1 个答案:

答案 0 :(得分:0)

Pavel让我明白,我的Tomcat服务器对dbcp 1.2有奇怪的依赖性。这可能是因为我首先创建了对dbcp 1.2的依赖。当我将后来的依赖项添加到1.4时,它不起作用。

我通过删除当前的Tomcat服务器并创建新的服务器来解决此问题。只是激进的方法,但我解决了我的问题。