下载后可任意编辑spring 常见错误总结 在学习 spring 过程中遇见了种种不同的异常错误,这里做了一下总结,希望遇见类似错误的同学们共勉一下。1. 错误一Error creating bean with name 'helloServiceImpl' defined in class path resource [spring-service.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'helloDao' of bean class [www.csdn.spring.service.impl.HelloServiceImpl]: Bean property 'helloDao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'helloDao' of bean class这类错误是:一般都是创建了一个 dao 的 spring 文件比如 spring-dao 有创建了一个 service 的spring 文件,在 spring-service.xml 中引用 dao 的中定义的 id 名,导致的错误,疏忽是:写service 实现类的时候忘记了写对应 dao 的 setter 方法,即所谓的依赖注入比如:private HelloDao helloDao;//set 依赖注入很重要,不写会报错,不能读写 helloDao 这一属性publicvoid setHelloDao(HelloDao helloDao) {System.out.println("控制反转:应用程序本身不在负责创建 helloDao 对象,而是由 spring 容器负责创建、管理、维护,这样控制权转移,称为反转。"+ "可以通过依赖注入方式注入该 HelloDao 对象");this.helloDao = helloDao;}2. 错误二Configuration problem: Failed to import bean definitions from relative location [spring-dao.xml]Offending resource: class path resource [spring.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 9 in XML document from class path resource [spring-dao.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Open quote is expected for attribute "{1}" associated with an element type "scope".Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 9 in XML...