java开发中错误记录汇总

json相关

1、在Apifox测试http请求,使用json格式的数据请求时,报错。

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<EOL> at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 2, column: 2]]

json数据格式错误,key需要使用双引号。

https相关

1、访问https协议的请求时,报错。

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、新建工程访问请求时出现。

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解决问题,经查二者区别如下:

  • @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接口实际路径对应,经查一致;
  • mapper接口方法和xml文件中的id是否一致,经查一致;
  • 查看yml文件中mapperLocations配置项,经查mapperLocations配置为:classpath*:mapper/Mapper.xml,修改为classpath:mapper/**/*Mapper.xml,重启测试ok。
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jinwen5290

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值