將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上編譯。