天天看点

在开发过程中出现 java.lang.StackOverflowError错误

在开发过程中出现 java.lang.StackOverflowError错误

    • java.lang.StackOverflowError
    • 解决方案:

java.lang.StackOverflowError

在我新增并且同时从新增后的表中查询数据的时候,报错了,以前从未见过这种错误,故在此记录一下并给出当时的解决方案

如下报错代码:

.

// 报错信息
十一月 21, 2018 10:05:04 上午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [springMVC] in context with path [/ssm-demo] threw exception [Handler processing failed; nested exception is java.lang.StackOverflowError] with root cause
java.lang.StackOverflowError
	at java.lang.ReflectiveOperationException.<init>(Unknown Source)
	at java.lang.reflect.InvocationTargetException.<init>(Unknown Source)
	at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.json.JSONObject.populateMap(JSONObject.java:1015)
	at org.json.JSONObject.<init>(JSONObject.java:279)
	at org.json.JSONObject.wrap(JSONObject.java:1527)
	at org.json.JSONObject.populateMap(JSONObject.java:1017)
	at org.json.JSONObject.<init>(JSONObject.java:279)
	at org.json.JSONObject.wrap(JSONObject.java:1527)
	at org.json.JSONObject.populateMap(JSONObject.java:1017)
	at org.json.JSONObject.<init>(JSONObject.java:279)
	at org.json.JSONObject.wrap(JSONObject.java:1527)
	at org.json.JSONObject.populateMap(JSONObject.java:1017)
	at org.json.JSONObject.<init>(JSONObject.java:279)
	at org.json.JSONObject.wrap(JSONObject.java:1527)
	at org.json.JSONObject.populateMap(JSONObject.java:1017)
	at org.json.JSONObject.<init>(JSONObject.java:279)
	at org.json.JSONObject.wrap(JSONObject.java:1527)
	at org.json.JSONObject.populateMap(JSONObject.java:1017)
	at org.json.JSONObject.<init>(JSONObject.java:279)
	at org.json.JSONObject.wrap(JSONObject.java:1527)
	……
	
           

解决方案:

两种情况,第一种情况,寻找报错的地方,我这里报错是在Mybatis的mappers文件中,select标签中漏写了resultType="String"参数,
所以,报了以上错误信息-
           
<select id="getContent" parameterType="String">
		select message from msg_tb where id=#{id}
</select>
           
第二种情况,运行项目的时候,登录不进你的项目首页,说明你的数据库服务已停止,需要打开任务管理器——服务——开始,重新启动MySQL服务
           
在开发过程中出现 java.lang.StackOverflowError错误

第三种情况,在设计数据库的时候,主键id没有设置为自增,或者唯一的字段冲突了