详细错误:
在浏览器请求接口时
There was an unexpected error (type=Internal Server Error, status=500). could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
查看console中错误:
clause and contains nonaggregated column ...
.which is not functionally dependent on columns in GROUP BY clause;
this is incompatible with sql_mode=only_full_group_by
错误原因:对于GROUP BY聚合操作,如果在SELECT中的列,没有在GROUP BY中出现,那么这个SQL是不合法的;
解决办法:1、检测MySQL版本:select @@version;(我的MySQL版本是5.7.24)
2、SET GLOBAL sql_mode = ''; (关掉ONLY_FULL_GROUP_BY)
3、重启MySQL(很重要!!!!);
参考:https://blog.csdn.net/yalishadaa/article/details/72861737
网友评论