日期:2014-05-19  浏览次数:20645 次

org.springframework.beans.NotWritablePropertyException:怎么解决。
XML code

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
        destroy-method="close">
        <!-- com.mchange.v2.c3p0.ComboPooledDataSource -->
        <!-- 指定连接数据库的驱动 -->
        <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
        <!-- 指定连接数据库的URL -->
        <property name="jdbcUrl" value="jdbc:mysql://localhost/cms"></property>
        <!-- 指定连接数据库的用户名 -->
        <property name="username" value="root"></property>
        <!-- 指定连接数据库的密码 -->
        <property name="password" value="123"></property>
        <!-- 指定连接数据库连接池的最大连接数 -->
        <property name="maxPoolSize" value="20"></property>
        <!-- 指定连接数据库连接池的最小连接数 -->
        <property name="minPoolSize" value="1"></property>
        <!-- 指定连接数据库连接池的初始化连接数 -->
        <property name="initialPoolSize" value="1"></property>
        <!-- 指定连接数据库连接池的连接的最大空闲时间 -->
        <property name="maxIdleTime" value="20"></property>
    </bean>


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'username' of bean class [com.mchange.v2.c3p0.ComboPooledDataSource]: Bean property 'username' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

username是连接数据库的登录名 为什么还要getter setter啊 求大侠解答

------解决方案--------------------
邪乎,是不是你的mysql数据库jar包导入的不对啊。在检查检查