【发布时间】:2018-10-02 12:24:27
【问题描述】:
我正在 Java Spring 中开发一个简单的 RESTfull 服务并使用 JDBCTemplate。
但是,我遇到了一个我不明白的运行时错误。它抱怨 SPRING_SESSION 表不存在,但是我认为 Spring 应该能够根据需要创建必要的表。
application.properties:
spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:mysql://localhost:3306/getfit?useSSL=false
spring.datasource.username=root
spring.datasource.password=***
例外:
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [DELETE FROM SPRING_SESSION WHERE EXPIRY_TIME < ?]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'getfit.SPRING_SESSION' doesn't exist
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:235) ~[spring-jdbc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) ~[spring-jdbc-5.0.4.RELEASE.jar:5.0.4.RELEASE]
异常是由一些试图从不存在的表中删除记录的进程触发的。
手动创建表会导致更多错误(不是现有列)。设置
hibernate.ddl-auto=update
也无济于事。
另外,我有 修改 MySQL 配置以允许大写字符,这也没有帮助。
有趣的是,这个问题发生在我格式化我的操作系统并从 github 克隆项目之后。在一切正常之前。
您有什么想法会出错吗?如果你需要我给你看一些代码,请告诉我。
感谢您关注这个:)
【问题讨论】: