欧美三级电影完整|亚洲一二三四久久|性爱视频精品一区二区免费在线观看|国产精品啪啪视频|婷婷六月综合操人妻视频网站|99爱免费视频在线观看|美女一级片在线观看|北京熟女88av|免费看黄色A级电影|欧美黄色毛片儿

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

2023-04-12


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

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

json相關


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相關


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

沒有驗證證書導致。解決方式,要么驗證,要么忽略。


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默認按照byType方式進行bean匹配,@Resource默認按照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接口實際路徑對應,經(jīng)查一致;
  • mapper接口方法和xml文件中的id是否一致,經(jīng)查一致;
  • 查看yml文件中mapperLocations配置項,經(jīng)查mapperLocations配置為:classpath*:mapper/Mapper.xml,修改為classpath:mapper/**/*Mapper.xml,重啟測試ok。



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

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