由jetty6升级为jetty9后,出现的问题

由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

猜你喜欢

转载自blog.csdn.net/xyr05288/article/details/82429126