In class Heart have Following variable
public class Heart {
private int noofheart;
private String nameOfAnimal;
这是我的bean.xml
<bean id="octopose" class="com.spring.auto.Heart">
<property name="nameOfAnimal" value="octopos"></property>
<property name="noofheart" value="3"></property>
</bean>
实际上属性标签无法正常工作,当我使用注释时,它给出了getter和Setter的错误,如下所示:
@Autowired
private Heart heart;
并且不使用getter和setter,但是我也检查了getter和setter但仍然无法正常工作,错误如下:Bean类[com.spring.auto.Heart]的无效属性'nameOfAnimal':Bean属性'nameOfAnimal'是不可写的,或者具有无效的setter方法。 setter的参数类型是否与getter的返回类型匹配? 在org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:243)
您需要执行语句,而不仅仅是准备语句:
stmt.executeUpdate();
此外,作为一种实践,您不应该假设连接自动提交,而是明确地提交自己:
conn.commit();