Spring with mySql

时间:2017-03-11 19:55:22

标签: mysql spring hibernate spring-boot

我的合作伙伴拥有相同的代码,但我是唯一一个遇到此问题的人。 我有相同的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

谢谢

2 个答案:

答案 0 :(得分:1)

您只是在数据库表中没有列roles。您应该更新您的数据库。您可以使用hibernate.hbm2ddl.auto=update

答案 1 :(得分:0)

看起来像是一个映射错误,检查实体的名称,pojo字段,数据库字段名称(如果设置为创建它)。确保它们都匹配,也许是关于大写字母的东西。 我担心我无法提供进一步的帮助。