天天看點

在開發過程中出現 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沒有設定為自增,或者唯一的字段沖突了