1 / 11
文档名称:

spring常见错误总结.doc

格式:doc   大小:65KB   页数:11页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

spring常见错误总结.doc

上传人:yzhluyin1 2016/12/23 文件大小:65 KB

下载得到文件列表

spring常见错误总结.doc

相关文档

文档介绍

文档介绍:计算机交流平台: 计算机故障_计算机论坛 spring 常见错误总结在学****spring 过程中遇见了种种不同的异常错误,这里做了一下总结,希望遇见类似错误的同学们共勉一下。 1. 错误一 Error creating bean with name 'helloServiceImpl' defined in class path resource [spring-]: Error setting property values; nested exception .: Invalid property 'helloDao' of bean class [.]: 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: : Invalid property 'helloDao' of bean class 这类错误是: 一般都是创建了一个 dao 的 spring 文件比如 spring-dao 有创建了一个 service 的 spring 文件,在 spring- 中引用 dao 的中定义的 id名, 导致的错误, 疏忽是:写 servic e 实现类的时候忘记了写对应 dao 的 setter 方法, 即所谓的依赖注入比如: private HelloDao helloDao; //set 依赖注入很重要,不写会报错,不能读写 helloDao 这一属性 publicvoid setHelloDao(HelloDao helloDao) { .println(" 控制反转: 应用程序本身不在负责创建 helloDao 对象, 而是由 spring 容器负责创建、管理、维护,这样控制权转移,称为反转。" +" 可以通过依赖注入方式注入该 HelloDao 对象"); = helloDao; } 2. 错误二 Configuration problem: Failed to import bean definitions from relative location [spring-]Offending resource: class path resource []; nested exception .: Line 9 in XML document from class path resource [spring-] is invalid; nested exception .: Open quote is expected for attribute "{1}" associated with an element type "scope". Caused by: : Line 9 in XML document from class path resource [spring-] is invalid; nested exception .: Open quote is expected for Caused by: : Open quote is expected for attribute "{1}" associated with an element type "scope". 这种错误是马虎的错误, 在对应的 spring 的配置文件中, bean 标签的 scope 属性忘了加引号, 在配置文件中国不会报错,但是在运行的时候就会出这样的错,一般导致错误的原因是复制的时候疏忽了引号,直接将原来的引号覆盖了,导致了最后该