SQLGrammarException异常处理办法

could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet

原因如下:
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = bytea
Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
Position: 40

解决办法:
该问题有两种情况,一种是数据库字段与你的实体类属性不一致,有可能是名字有可能是类型,更改后即可。
第二种情况:先在网页上按F12打开控制台,操作后观察控制台的Headers的Content-type是不是application/json,如果是,后端需要用@RequestBody注解接收数据,如果是带www的,后端需要用@RequestParam接收参数,具体原因是前端在用JSon传的过程中,如果后端不用相对应的注解接收,会在接受的时候改变其类型,导致于数据库类型不匹配。(我测了POST,GET等应该也是,不过GET一般都是用@RequestParam接收参数)

posted @ 2021-06-30 16:05  咱那飘逸的长发  阅读(1262)  评论(0)    收藏  举报