关于“Cannot resolve table 'user'”报错及运行日志报java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone的问题解决
springboot+vue建立映射时,后端引用@Table(name=“user”) 来对应表名 user,但引用后报错“Cannot resolve table 'user'”,尝试了多篇博主的博文后,问题解决,现在总结一下各位大佬的方法:
第一:View-->Tool windows-->Database-->Data Source-->MySQL输入Host、Port和账号密码进行测试
如果报Server returns invalid timezone. Need to set 'serverTimezone' property.在URL后缀加上?serverTimezone=GMT%2B8
测试成功后,Apply后点击OK
第二:View-->Tool windows-->Persistence后双击“entityManagerFactory”右键选择Assign Data Sources加载刚才建的Database
上述两步执行后还报“Cannot resolve table 'user'”的话,尝试以下操作File-->Settings-->Editor-->Code Style-->Inspections取消JPA的勾选框。
在后端工程运行中如果报“java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.”,在application.properties配置文件的spring.datasource.url的值后边加上
?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC,如图: