数据库“默认”需要发展!当尝试使用播放框架2.7.0和Ebean连接到MySQL时

时间:2019-04-25 07:13:53

标签: java mysql playframework ebean

我正在尝试使用Play框架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:

如果我将其标记为已解决,则将显示“播放问候”页面。但是我认为这是不正确的,并且我在项目中添加了一个Task模型,因此我认为应该将其创建为数据库中的表,但事实并非如此。

我的设置有问题吗?


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

1 个答案:

答案 0 :(得分:0)

在某些情况下,您使用了错误的定界符。从命令行检查代码,然后再将其添加到演进中。

示例:

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;