【问题标题】:Database 'default' needs evolution! when trying connect to MySQL with play framework 2.7.0 and Ebean数据库“默认”需要进化!尝试使用 play framework 2.7.0 和 Ebean 连接到 MySQL 时
【发布时间】:2019-04-25 07:13:52
【问题描述】:

我正在尝试使用 play framework 2.7.0 建立一个项目,现在我正在尝试使用 sbt-play-ebean 5.0.0 连接到 MySQL 数据库。

这是我的代码。 https://github.com/hiroya8649/play-mysql-ebean-test

以下是您可能要检查的文件:

https://github.com/hiroya8649/play-mysql-ebean-test/blob/master/conf/application.conf

https://github.com/hiroya8649/play-mysql-ebean-test/blob/master/build.sbt

https://github.com/hiroya8649/play-mysql-ebean-test/blob/master/project/plugins.sbt

现在我尝试连接到 localhost:9000,它告诉我 Database 'default' needs evolution! An SQL script will be run on your database 和一个 run this script 按钮。

这个脚本也是一样的:https://github.com/hiroya8649/play-mysql-ebean-test/blob/master/conf/evolutions/default/1.sql 但是如果我点击run this script它会告诉我

Evolution has not been applied properly. Please check the problem and resolve it manually before marking it as resolved. -
We got the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delimiter $$ -- -- PROCEDURE: usp_ebean_drop_foreign_keys TABLE, COLUMN -- delete' at line 1 [ERROR:1064, SQLSTATE:42000], while trying to run this SQL script:

如果我只是将其标记为已解决,则会显示 play hello world 页面。但我觉得不正确,我在项目中添加了Task 模型,所以我认为它应该在数据库中创建为表但它没有。

我的设置有什么问题吗?


我在 playframework 和 play-ebean GitHub 中发现了同样的问题,它似乎发生在 play 版本 2.6.20 并且尚未修复。

【问题讨论】:

    标签: java mysql playframework ebean


    【解决方案1】:

    在某些情况下,您使用了错误的分隔符。在将代码添加到进化之前,请从命令行检查您的代码。

    例子:

    https://github.com/hiroya8649/play-mysql-ebean-test/blob/master/conf/evolutions/default/1.sql#L10

    https://github.com/hiroya8649/play-mysql-ebean-test/blob/master/conf/evolutions/default/1.sql#L40

    delimiter $$
    ....
    DROP PROCEDURE IF EXISTS usp_ebean_drop_column;
    

    你需要改成:

    DROP PROCEDURE IF EXISTS usp_ebean_drop_column$$
    

    或者:

    delimiter $$
    ...
    delimiter ;
    DROP PROCEDURE IF EXISTS usp_ebean_drop_column;
    

    【讨论】:

    • 嗯。不过这是生成的,不是我写的。我应该自己更改吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-05
    • 1970-01-01
    • 2011-10-06
    • 2018-12-12
    • 2013-02-21
    • 1970-01-01
    相关资源
    最近更新 更多