由jetty6升級為jetty9後,出現的問題
阿新 • • 發佈:2018-11-26
由jetty6升級為jetty9後,出現的問題:
1.升級jetty9 執行出現兩個RequestMappingHandlerAdapter bean
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#1'
原因:
之前的xml配置
<mvc:annotation-driven /> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> <property name="messageConverters"> <list> <bean class="org.springframework.http.converter.FormHttpMessageConverter"></bean> <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"></bean> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/plain;charset=UTF-8</value> </list> </property> </bean> </list> </property> </bean>
之後在網上看到了這篇文章:https://blog.csdn.net/xingbear/article/details/77838219
發現是mvn:annotation-driven的影響,<mvc:annotation-driven>會自動註冊RequestMappingHandlerMapping與RequestMappingHandlerAdapter兩個Bean,這是Spring MVC為@Controller分發請求所必需的,並且提供了資料繫結支援,@NumberFormatannotation支援,@DateTimeFormat支援,@Valid支援讀寫XML的支援(JAXB)和讀寫JSON的支援(預設Jackson)等功能。
修改後的springmvc-config.xml:
<mvc:annotation-driven > <mvc:message-converters> <bean class="org.springframework.http.converter.FormHttpMessageConverter"></bean> <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"></bean> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/plain;charset=UTF-8</value> </list> </property> </bean> </mvc:message-converters> </mvc:annotation-driven>
2.jetty6升級為jetty9之後,出現了maven jar包不相容的情況,因為jetty版本與jdk版本和servlet-api版本都有緊密聯絡
參考文章:https://blog.csdn.net/jkdcoach/article/details/54311381
版本號 | 釋出及維護年份 | 託管平臺 | JVM版本 | 支援的協議 | servlet版本 | JSP版本 | 目前狀態 |
---|---|---|---|---|---|---|---|
9.3 | 2015 | Eclipse | 1.8 | HTTP/1.1 (RFC 7230), HTTP/2 (RFC 7540), WebSocket (RFC 6455, JSR 356), FastCGI | 3.1 | 2.3 | Stable |
9.2 | 2014 | Eclipse | 1.7 | HTTP/1.1 RFC2616,javax.websocket, SPDY v3 | 3.1 | 2.3 | Stable |
8 | 2009-至今 | Eclipse/Codehaus | 1.6 | HTTP/1.1 RFC2616, WebSocket RFC 6455, SPDY v3 | 3.0 | 2.2 | Mature |
7 | 2008-至今 | Eclipse/Codehaus | 1.5 | HTTP/1.1 RFC2616, WebSocket RFC 6455, SPDY v3 | 2.5 | 2.1 | Mature |
6 | 2006-2010 | Codehaus | 1.4-1.5 | HTTP/1.1 RFC2616 | 2.5 | 2.0 | Venerable |
5 | 2003-2009 | Sourceforge | 1.2-1.5 | HTTP/1.1 RFC2616 | 2.4 | 2.0 | Deprecated |
4 | 2001-2006 | Sourceforge | 1.2,J2ME | HTTP/1.1 RFC2616 | 2.3 | 1.2 | Ancient |
3 | 1999-2002 | Sourceforge | 1.2 | HTTP/1.1 RFC2068 | 2.2 | 1.1 | Fossilized |
2 | 1998-2000 | Mortbay | 1.1 | HTTP/1.0 RFC1945 | 2.1 | 1.0 | Legendary |
1 | 1995-1998 | Mortbay | 1.0 | HTTP/1.0 RFC1945 | – | – | Mythical |