一,Spring Bean 管理
1.打错
a.
问题:xsi:schemaLocation 没写完
报错:org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 63; SchemaLocation: schemaLocation 值 'http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context' 必须具有偶数个 URI。
b.
问题:Bean的名字写错了,我没命名应该是默认userController
报错:No bean named 'UserController' available
c.
问题:应该是@Resource没注入成功,不知道哪不对
报错: Cannot invoke "com.itheima.assemble.dao.UserDao.save()" because "this.userDao" is null
2.版本问题
a.
问题:无法识别Resource。没引入包/依赖(书落后了)
解决:这个文章里的网站,能搜需要的包查看groupId,artifactId,version信息,就可以用maven引入了。好像下载spring的那个文档里也能看,我没找
(118条消息) Cannot resolve symbol 'Resource'_天已青色等烟雨来的博客-CSDN博客
Maven Repository: javax.annotation » javax.annotation-api » 1.3.2 (mvnrepository.com)
报错:Cannot resolve symbol 'Resource'
b.
问题:JDK版本与spring版本不匹配
(121条消息) Spring Framework与JDK版本对应关系_springframework版本怎么看_行者无疆_ty的博客-CSDN博客
报错:Failed to read candidate component class
3.不知道是啥
a.
报错:
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class(无法读取候选组件类): file [C:\ICreate\HWJ2\Spring\Chapter7ManageBean_I_S_A_L\target\classes\com\itheima\AnnotationTest.class];
nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: (ASM ClassReader 无法解析类文件 - 可能是由于尚不支持新的 Java 类文件版本:)file [C:\ICreate\HWJ2\Spring\Chapter7ManageBean_I_S_A_L\target\classes\com\itheima\AnnotationTest.class];
nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 64(不支持的类文件主要版本 64)
b.
报错:Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 6 in XML document from class path resource [ContextUser.xml] is invalid;
nested exception is org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 53; cvc-complex-type.2.4.c: 通配符的匹配很全面, 但无法找到元素 'context:componet-scan' 的声明。
二.Spring AOP
1.打错了
a.
ClassLoader classLoader = MyProxy.class.getClassLoader(); 我写的是Proxy.class.getClassLoader(); 以及spring写成spirng
报错com.itheima.demo01.UserDao referenced from a method is not visible from class loader