Failed to read candidate component class错误分析
将spring从3.1升级到3.2启动tomcat出现如上错误,
仔细检查过web.xml中关于spring配置引入,spring-mvc配置引入都没有问题,
以及spring配置文件读取方式,包括监听参数配置也是对的,
关于引入和监听web.xml配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | <?xml version= "1.0" encoding= "UTF-8" ?> <beans xmlns= "http://www.springframework.org/schema/beans" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns:p= "http://www.springframework.org/schema/p" xmlns:context= "http://www.springframework.org/schema/context" xmlns:mvc= "http://www.springframework.org/schema/mvc" xmlns:aop= "http://www.springframework.org/schema/aop" xmlns:tx= "http://www.springframework.org/schema/tx" xsi:schemaLocation=" http: //www.springframework.org/schema/beans http: //www.springframework.org/schema/beans/spring-beans.xsd http: //www.springframework.org/schema/context http: //www.springframework.org/schema/context/spring-context-4.1.xsd http: //www.springframework.org/schema/mvc http: //www.springframework.org/schema/mvc/spring-mvc-4.1.xsd http: //www.springframework.org/schema/aop http: //www.springframework.org/schema/aop/spring-aop-4.1.xsd http: //www.springframework.org/schema/tx http: //www.springframework.org/schema/tx/spring-tx-4.1.xsd "> <!-- 注解 --> <!-- 注解映射器 --> <!-- <bean class = "org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" ></bean> 注解适配器 <bean class = "org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" ></bean> --> <!-- 使用mvc的注解驱动可以代替 上面声明的两个适配器 映射器 ,开发中建议使用该种方式--> <mvc:annotation-driven></mvc:annotation-driven> <context:component-scan base- package = "com.richard.ssm.controller" ></context:component-scan> <!-- 非注解 --> <!-- 处理器适配器 --><!-- 以bean的name属性值作为url --> <bean class = "org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" ></bean> <!-- 另一个处理器适配器 --> <bean class = "org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter" ></bean> <!-- 处理器映射器 --> <bean class = "org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" ></bean> <!-- 配置 ItemController1--> <bean id= "ItemController1id" name= "/queryitem.action" class = "com.richard.ssm.controller.ItemController1" ></bean> <!-- 配置 ItemController2--> <bean id= "ItemController2id" name= "/queryitem2.action" class = "com.richard.ssm.controller.ItemController2" ></bean> <!-- 简单的URL映射 对同一个Controller 多个action做映射配置 多个url映射可以并存--> <bean class = "org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" > <property name= "mappings" > <props> <!-- 对itmescontroller1进行url映射 --> <prop key= "/queryitem11.action" >ItemController1id</prop> <prop key= "/queryitem12.action" >ItemController1id</prop> <prop key= "/queryitem21.action" >ItemController2id</prop> </props> </property> </bean> <!-- 解析jsp的视图解析器 --> <bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver" ></bean> </beans> |
换回成3.1又没有问题,换成3.2又不行,查看编译环境用的是1.8,将1.8降为1.7,问题解决,服务启动正常,
也就是说spring 3.2不支持1.8编译环境,解决办法就是降为1.7编译环境
关于编译环境配置如图:
spring官网说了,要使用java8,只支持spring 4.X以上版本,而spring的使用最低java要求java5及以上,
如果出现例外,那就例外说了,比如一开始spring 3.1就可以在java8上编译。
作者:RichardCui
出处:https://www.cnblogs.com/yachao1120/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。该文章也同时发布在我的独立博客中-RichardCuiBlog。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步