BUG总结

BUG总结前后端分离

(1)java.lang.IllegalStateException

Unsatisfied dependency expressed through field 'videoClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.lsl.eduservice.client.VideoClient': Unexpected exception during be

.IllegalStateException: Failed to introspect Class [org.springframework.cloud.context.properties.ConfigurationPropertiesBe

报错主要是这两个,其实都是依赖的问题,没找到,因为springboot和springcloud的版本不对应,我这里改成了spring boot 2.2.12.2.1.RELEASE,对应springcloud Hoxton.RELEASE

这种依赖问题就检查版本,还有是否真的已经下载下来,如果是没下载下来,可以下载jar,然后通过本地导入仓库,即可使用。

(2)java.lang.IllegalArgumentException: no server available

原因,nacos 服务没找到,没开启nacos、没有配置nacos。

(3)Access to XMLHttpRequest

(index):1 Access to XMLHttpRequest at
‘http://localhost:9001/’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: No
‘Access-Control-Allow-Origin’ header is present on the requested resource.

一眼看上去跨域问题,是吧,检查springboot里面是否加了注解
@CrossOrigin,nginx中是否配置了对应的端口:
在这里插入图片描述
如果都加了,没问题,检查你前端的路径URL,这是这个大写,™的XX,只能是小写,大写就会报跨域。。。。
在这里插入图片描述
如果配置对,那么请仔细观察你的大小写,或者单词、关键字,括号是否有误。

(4)、org.springframework.http.converter.HttpMessageNotReadableExc

http 信息不可读异常,@RequestBody在post、put中用于接受json数据,不能用get请求,@requestParam接收的是key-value形式的参数,

注意,写json数据的时候,不要在最后一位加逗号’,’,
在这里插入图片描述
,password后面不能加逗号,
会报

org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unexpected character (’}’ (code 125)): was expecting double-quote to start field name; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character (’}’ (code 125)): was expecting double-quote to start field name
json格式错误,导致的问题,

解决办法: 将get请求修改为post请求,或者将它修改为可以用json接收的请求方式。

5、Unexpected token o in JSON at position 1

前端,json字符串转json对象时报错,JSON.parse()参数严格要求,是json字符串,看看你传的类型到底是什么,我这里因为传过来的是对象,使用需要先使用JSON.stringify()对象转json字符串,然后在使用JSON.parse() json字符串转json对象。
在这里插入图片描述

6、前端报500

404表示未找到请求,也就是你写错了url地址,或者参数或者其他,500后端服务器异常,也就是后端的问题了,可能是没接受参数,也可能是服务器挂了,等各种原因,建议仔细观察,debug看看值传进来没,拿到值了没有,等,debug YYDS。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值