我的伙伴有相同的代码,但我是唯一遇到此问题的人。 我有相同的 mySql 和 Spring 版本。这是我得到的异常:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataBaseUsage': Invocation of init method failed;
nested exception is
org.springframework.dao.InvalidDataAccessResourceUsageException:
could not execute statement; SQL [n/a]; nested exception is
org.hibernate.exception.SQLGrammarException: could not execute statement
Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException:
could not execute statement; SQL [n/a]; nested exception is
org.hibernate.exception.SQLGrammarException: could not execute statement
Caused by: org.hibernate.exception.SQLGrammarException:
could not execute statement
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Unknown column 'roles' in 'field list'
DataBaseUsage是@Controller
谢谢
最佳答案
您只是在数据库表中没有列roles
。您应该更新您的数据库。您可以使用hibernate.hbm2ddl.auto=update
。
关于mysql - Spring 与 mySql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42739905/