SpringMVC的400错误日志输出问题

发布于 2022-01-07 13:40:21 字数 9317 浏览 894 评论 1

错误详情:

org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not instantiate value of type [simple type, class com.skynet.data.bean.Function] from Integral number (9); no single-int-arg constructor/factory method



这很简单的错误,一眼就看出问题所在,问题是我们的环境,这个只给客户端一个400错误码,根本不知道具体错误,日志也没有输出。还要一步一步断点到SpringMVC的源码去看错误详情。

原因也知道了:配置中使用

<mvc:annotation-driven>
		<mvc:message-converters register-defaults="true">
			<bean class="com.***.web.util.ObjectHttpMessageConverter" />
		</mvc:message-converters>
	</mvc:annotation-driven>



转换提交参数到controller方法的对象参数出问题了,然后被SpringMVC默认的错误处理器处理了,返回400。

问题是这个错误日志为什么不输出::

maven:

<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${spring.version}</version>
			<exclusions>
	            <exclusion>
	                <groupId>commons-logging</groupId>
	                <artifactId>commons-logging</artifactId>
	            </exclusion>
        	</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>${spring.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependency>
		<dependency>
			<groupId>commons-fileupload</groupId>
			<artifactId>commons-fileupload</artifactId>
			<version>1.3.1</version>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-core</artifactId>
			<version>${jackson.core.version}</version>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>${jackson.core.version}</version>
		</dependency>
		<dependency>
			<groupId>org.codehaus.jackson</groupId>
			<artifactId>jackson-mapper-asl</artifactId>
			<version>${jackson.version}</version>
		</dependency>
		<dependency>
			<groupId>org.json</groupId>
			<artifactId>json</artifactId>
			<version>20141113</version>
		</dependency>
		<dependency>
			<groupId>com.ning</groupId>
			<artifactId>async-http-client</artifactId>
			<version>1.9.31</version>
		</dependency>
		<dependency>
			<groupId>org.apache.tomcat</groupId>
			<artifactId>tomcat-servlet-api</artifactId>
			<version>${tomcat.version}</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-api</artifactId>
			<version>2.3</version>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-core</artifactId>
			<version>2.3</version>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-jcl</artifactId>
			<version>2.3</version>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-web</artifactId>
			<version>2.3</version>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-slf4j-impl</artifactId>
			<version>2.3</version>
		</dependency>

		<dependency>
			<groupId>com.datastax.cassandra</groupId>
			<artifactId>cassandra-driver-mapping</artifactId>
			<version>2.1.7</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-cassandra</artifactId>
			<version>1.2.2.RELEASE</version>
		</dependency>
		<!-- dependency> <groupId>org.apache.solr</groupId> <artifactId>solr-solrj</artifactId> 
			<version>5.4.0</version> </dependency -->

		<!-- dependency> <groupId>com.huawei.openstore</groupId> <artifactId>uploader-sdk</artifactId> 
			<version>0.0.2-SNAPSHOT</version> </dependency> <dependency> <groupId>com.huawei.openstore</groupId> 
			<artifactId>oauth2-json</artifactId> <version>0.3.5</version> </dependency -->
		<!-- Huawei dependency -->
		<dependency>
			<groupId>com.huawei.esdk</groupId>
			<artifactId>obs-sdk</artifactId>
			<version>0.0.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
			<version>4.5.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpcore</artifactId>
			<version>4.4.4</version>
		</dependency>
		<dependency>
			<groupId>com.jamesmurty.utils</groupId>
			<artifactId>java-xmlbuilder</artifactId>
			<version>1.0</version>
		</dependency>
		<dependency>
			<groupId>jdom</groupId>
			<artifactId>jdom</artifactId>
			<version>1.1</version>
		</dependency>
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
			<version>1.2.17</version>
		</dependency>

		<!-- Huawei dependency end -->

		<dependency>
			<groupId>org.apache.tiles</groupId>
			<artifactId>tiles-core</artifactId>
			<version>${tiles.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.tiles</groupId>
			<artifactId>tiles-jsp</artifactId>
			<version>${tiles.version}</version>
		</dependency>

		<!-- JPush dependency start -->
		<dependency>
			<groupId>cn.jpush.api</groupId>
			<artifactId>jpush-client</artifactId>
			<version>3.2.8</version>
		</dependency>




我自己跟踪到:

org. springframework. web. servlet. handler. AbstractHandlerExceptionResolver.logException

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瀞厅☆埖开 2022-01-07 14:57:05

t'wen

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文