构造器注入
1.即使在jdk的lib中添加了spring的包,配置了Maven,eclipse还是无法识别springframework,报错“The import org.springframework.test cannot be resolved"
以及无法识别xml文件中的bean,报错“Cannot find the declaration of element 'beans'”
解决方法:按照框架开发课本第9页的图示,发现自己的项目没有WEB-INF目录,结合之前学过的web课,发现应该创建web项目,将相关的spring的jar包放到WEB-INF的lib,而不是jdk的lib中。
2.写注入@Override时,报错“Syntax error , insert “EnumBody” to complete EnumDeclaration”,发现自己的TestDaoImp1创建的还是接口类,既然是重写就一定是继承某个类继承类,应加上implements,把interface改成class,而后就可以重写父类中的类了。
3.新建xml报错:No grammar constraints (DTD or XML Schema) referenced in the document.
参考https://blog.csdn.net/qq_36620997/article/details/82765368
4.简单例子参考https://www.bilibili.com/video/BV1iE41137iX/?spm_id_from=333.788&vd_source=af888e4b9fbc70c4d5e7a445796ae8a1

浙公网安备 33010602011771号