在mysql中,Play framework 2.2.2的演变不会被触发
在示例todo应用程序播放中文档中,使用mysql创建tasks表并不是在创建演进。我试着用在mysql中,Play framework 2.2.2的演变不会被触发,mysql,scala,playframework,playframework-2.0,scala-2.10,Mysql,Scala,Playframework,Playframework 2.0,Scala 2.10,在示例todo应用程序播放中文档中,使用mysql创建tasks表并不是在创建演进。我试着用 applyEvolutions.default=true 在application.conf中。甚至尝试用 start -DapplyEvolutions.default=true mysql查询也不是问题,因为在mysql控制台中手动输入它可以使其正常工作。db连接也没有问题,因为在手动创建表之后,插入和删除操作在应用程序中运行良好 如需进一步参考,请访问application.conf
applyEvolutions.default=true
在application.conf中。甚至尝试用
start -DapplyEvolutions.default=true
mysql查询也不是问题,因为在mysql控制台中手动输入它可以使其正常工作。db连接也没有问题,因为在手动创建表之后,插入和删除操作在应用程序中运行良好
如需进一步参考,请访问application.conf
# This is the main configuration file for the application.
# ~~~~~
# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
# If you deploy your application to several instances be sure to use the same key!
application.secret="PwleF1NyxkZ[8Oq`j`^NMg:6Vu6MMiHv?s:Ff>3@VpiKfA^9qSvb/E_>5[BRq>h6"
# The application languages
# ~~~~~
application.langs="en"
# Global object class
# ~~~~~
# Define the Global object class for this application.
# Default to Global in the root package.
# application.global=Global
# Router
# ~~~~~
# Define the Router object to use for this application.
# This router will be looked up first when the application is starting up,
# so make sure this is the entry point.
# Furthermore, it's assumed your route file is named properly.
# So for an application router like `my.application.Router`,
# you may need to define a router file `conf/my.application.routes`.
# Default to Routes in the root package (and conf/routes)
# application.router=my.application.Routes
# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
# db.default.driver=org.h2.Driver
# db.default.url="jdbc:h2:mem:play"
# db.default.user=sa
# db.default.password=""
# Evolutions
# ~~~~~
# You can disable evolutions if needed
# evolutionplugin=disabled
applyEvolutions.default=true
DapplyDownEvolutions.default=true
# Logger
# ~~~~~
# You can also configure logback (http://logback.qos.ch/),
# by providing an application-logger.xml file in the conf directory.
# Root logger:
logger.root=ERROR
# Logger used by the framework:
logger.play=INFO
# Logger provided to your application:
logger.application=DEBUG
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost/sql_test"
db.default.user="testuser"
db.default.pass=""
这里是1.sql
# Tasks schema
# --- !Ups
CREATE TABLE task (
id int NOT NULL AUTO_INCREMENT,
label varchar(255),
PRIMARY KEY (ID)
);
# --- !Downs
DROP TABLE task;
检查以下各项:
您的evolution文件(1.sql、2.sql等)应该位于conf/evolutions/default/目录中,其中default是您在application.conf中为数据库指定的名称。我的意思是说
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost/sql_test"
db.default.user="testuser"
db.default.pass=""
接下来,检查您是否已经设置了自动应用于application.conf的evolutions和down evolutions,并且evolutionplugin设置为enabled
evolutionplugin=enabled
applyEvolutions.default=true
applyDownEvolutions.default=true
注意:在application.conf中有DapplyDownEvolutions
# This is the main configuration file for the application.
# ~~~~~
# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
# If you deploy your application to several instances be sure to use the same key!
application.secret="PwleF1NyxkZ[8Oq`j`^NMg:6Vu6MMiHv?s:Ff>3@VpiKfA^9qSvb/E_>5[BRq>h6"
# The application languages
# ~~~~~
application.langs="en"
# Global object class
# ~~~~~
# Define the Global object class for this application.
# Default to Global in the root package.
# application.global=Global
# Router
# ~~~~~
# Define the Router object to use for this application.
# This router will be looked up first when the application is starting up,
# so make sure this is the entry point.
# Furthermore, it's assumed your route file is named properly.
# So for an application router like `my.application.Router`,
# you may need to define a router file `conf/my.application.routes`.
# Default to Routes in the root package (and conf/routes)
# application.router=my.application.Routes
# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
# db.default.driver=org.h2.Driver
# db.default.url="jdbc:h2:mem:play"
# db.default.user=sa
# db.default.password=""
# Evolutions
# ~~~~~
# You can disable evolutions if needed
# evolutionplugin=disabled
applyEvolutions.default=true
DapplyDownEvolutions.default=true
# Logger
# ~~~~~
# You can also configure logback (http://logback.qos.ch/),
# by providing an application-logger.xml file in the conf directory.
# Root logger:
logger.root=ERROR
# Logger used by the framework:
logger.play=INFO
# Logger provided to your application:
logger.application=DEBUG
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost/sql_test"
db.default.user="testuser"
db.default.pass=""
除了应用程序的配置之外,还有一些其他需要检查的事项:
希望这能有所帮助。此外,请确保
libraryDependencies += evolutions
在您的build.sbt
中,因为它已成为一个外部模块
关于进化的更多信息:他们有关于mysql进化的日志吗?非常感谢。我被困在默认文件夹中,我把它命名为“sql\U测试”。将文件夹更改为“默认”有效。谢谢。