springboot实战异常问题总结

最近在用springboot写一个实战项目,遇到了些问题以及异常。现在总结一下:

1、在进行添加时,出现了id没有默认值

原来是在建数据库时,不小心没有设置id(主键)自动递增。

2、在进行文件上传下载时,文件上传一直报错

然后找了好久,最后确定是教师工号没有获取到,将教师工号integer改为string类型后上传成功。

3、在进行命名规范改包名时,出现如下异常

Caused by: java.lang.ClassNotFoundException: Cannot find class: leaves

是因为找不到这个类,可以去yml文件加上

type-aliases-package: cn.zcbigdata.mybits.entity

或者在xml文件加上

cn.zcbigdata.mybits.entity.Tea

4、在进行命名规范改包名时,还出现了以下异常

Description:Field leavesMapper in cn.zcbigdata.mybitsdemo.service.Impl.LeavesServiceImpl required a bean of type 'cn.zcbigdata.mybitsdemo.mapper.LeavesMapper' 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 'cn.zcbigdata.mybitsdemo.mapper.LeavesMapper' in your configuration.

是包名改变了但启动项没有改变,去启动项找

@MapperScan("cn.zcbigdata.mybits.mapper") //扫描的mapper

5、还出现了

Description:Field filepathService in cn.zcbigdata.mybitsdemo.controller.UploadController required a bean of type 'cn.zcbigdata.mybitsdemo.service.FilepathService' 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 'cn.zcbigdata.mybitsdemo.service.FilepathService' in your configuration.

去serviceimpl找,service注解有错误

加上service注解即可

然后就是分析问题流程

首先是前台分析

404错误:请求路径错了,前后台路径不一致

405错误:请求方式错了,例如:后台只支持post请求,前台却用了get请求

400错误:前后台参数类型不一致

然后是后台分析

500错误:后台服务错误,后台控制台有错误日志

如果前后台都没有报错

可以在后台打印参数或者idea用debug调试查看每一行代码运行的结果

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

herrybody

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

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

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

打赏作者

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

抵扣说明:

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

余额充值