2 eirc0522 eirc0522 于 2013.11.27 16:52 提问

常见的SSH执行save方法报错,

报错:Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'driverClassName' of bean class [com.mchange.v2.c3p0.ComboPooledDataSource]: Bean property 'driverClassName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

页面代码: private static PersonDAO psd;
private static ApplicationContext cxt;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
try {
cxt = new ClassPathXmlApplicationContext("beans.xml");
psd =(PersonDAO)cxt.getBean("serivceBean");
} catch (Exception e) {
e.printStackTrace();
}
}

@Test
public void testSave() {
    psd.save(new Person("xxx"));
}

业务bean:
@Resource private SessionFactory sessionFactoy;

public void save(Person person) {
    sessionFactoy.getCurrentSession().persist(person);
}

实体类:
private Integer id;
private String username;

    public Person(){}
    public Person(String username) {
        this.username = username;
    }
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }

beans.xml:
destroy-method="close">
.....

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!