亚洲欧美日韩熟女|做爱高潮视频网址|国产一区二区三级片|国产Av中文字幕www.性色av|亚洲婷婷永久免费|国产高清中文字幕|欧美变态网站久re视频精品|人妻AV鲁丝第一页|天堂AV一区二区在线观看|综合 91在线精品

java開發(fā)中錯誤記錄匯總

2023-04-12


java開發(fā)中錯誤記錄匯總

  • json相關(guān)
  • https相關(guān)
  • springboot
  • No adapter for handler
  • 'RedisTemplate' that could not be found.
  • Invalid bound statement (not found)

json相關(guān)


1、在Apifox測試http請求,使用json格式的數(shù)據(jù)請求時,報錯。


Resolved [org.springframework.http.converter.HttpMessageNotReadableException: 
JSON parse error: 
Unexpected character ('u' (code 117)): 
was expecting double-quote to start field name;
 nested exception is com.fasterxml.jackson.core.JsonParseException: 
 Unexpected character ('u' (code 117)): 
 was expecting double-quote to start field name at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 2, column: 2]]

json數(shù)據(jù)格式錯誤,key需要使用雙引號。


https相關(guān)


1、訪問https協(xié)議的請求時,報錯。


sun.security.validator.ValidatorException: 
PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: 
unable to find valid certification path to requested target

沒有驗證證書導(dǎo)致。解決方式,要么驗證,要么忽略。


springboot


No adapter for handler


1、新建工程訪問請求時出現(xiàn)。


javax.servlet.ServletException: No adapter for handler [com.spring.demo.web.GreetingController@3f37413a]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler
	at org.springframework.web.servlet.DispatcherServlet.getHandlerAdapter(DispatcherServlet.java:1302) ~[spring-webmvc-5.3.19.jar:5.3.19]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1050) ~[spring-webmvc-5.3.19.jar:5.3.19]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.19.jar:5.3.19]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.19.jar:5.3.19]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.19.jar:5.3.19]

沒有HandlerAdapter適配器。原因是我的Controller沒有正確配置RequestMapping。


‘RedisTemplate’ that could not be found.


2、集成redis,啟動時報錯如下:


Field redisTemplate in com.example.common.redis.RedisBean required a bean of type 'org.springframework.data.redis.core.RedisTemplate' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'org.springframework.data.redis.core.RedisTemplate' in your configuration.

解決辦法:將@Autowired改為@Resource解決問題,經(jīng)查二者區(qū)別如下:


  • @Autowired默認(rèn)按照byType方式進行bean匹配,@Resource默認(rèn)按照byName方式進行bean匹配
  • @Autowired是Spring的注解,@Resource是J2EE的注解

Invalid bound statement (not found)


mybatis集成報錯:


Invalid bound statement (not found): com.soft.mapper.test.SysRoleMapper.selectRoleList

解決辦法:


  • 查詢xml文件中namespace是否和mapper接口實際路徑對應(yīng),經(jīng)查一致;
  • mapper接口方法和xml文件中的id是否一致,經(jīng)查一致;
  • 查看yml文件中mapperLocations配置項,經(jīng)查mapperLocations配置為:classpath*:mapper/Mapper.xml,修改為classpath:mapper/**/*Mapper.xml,重啟測試ok。



本文僅代表作者觀點,版權(quán)歸原創(chuàng)者所有,如需轉(zhuǎn)載請在文中注明來源及作者名字。

免責(zé)聲明:本文系轉(zhuǎn)載編輯文章,僅作分享之用。如分享內(nèi)容、圖片侵犯到您的版權(quán)或非授權(quán)發(fā)布,請及時與我們聯(lián)系進行審核處理或刪除,您可以發(fā)送材料至郵箱:service@tojoy.com