开发者

how to resolve org.springframework.beans.NotWritablePropertyException

开发者 https://www.devze.com 2023-02-13 08:07 出处:网络
hi i am using spring config.xml to config my embedded database hsqldb. my spring config is as below: <jdbc:embedded-databas开发者_StackOverflow中文版e id=\"dataSource\" type=\"HSQL\">

hi i am using spring config.xml to config my embedded database hsqldb. my spring config is as below:

<jdbc:embedded-databas开发者_StackOverflow中文版e id="dataSource" type="HSQL">
    <jdbc:script location="classpath:schema.sql" />

</jdbc:embedded-database>
<bean id="adapterDataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="datasource" ref="dataSource"></property>
    <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
    <property name="url" value="jdbc:hsqldb:file:data/db/lmexadapter_db" />
    <property name="username" value="sa" />
    <property name="password" value="" />
</bean>

when run run my appication which is using above spring config.xml it give me a exception as below:

org.springframework.beans.NotWritablePropertyException: Invalid property 'datasource' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'datasource' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

please help to resolve this as soon as possible

Thank you


The issue is that org.apache.commons.dbcp.BasicDataSource doesn't have a "setDatasource" method. It does have a protected field "datasource", however, which you could expose by subclassing and providing a setter.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号