Failed to read candidate component class错误分析

 

将spring从3.1升级到3.2启动tomcat出现如上错误,
仔细检查过web.xml中关于spring配置引入,spring-mvc配置引入都没有问题,

以及spring配置文件读取方式,包括监听参数配置也是对的,

关于引入和监听web.xml配置如下:

<?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上编译。

posted @ 2019-03-23 14:51  小猫钓鱼吃鱼  阅读(10603)  评论(1编辑  收藏  举报