找到更多的细节你可能会发现有用的一些技巧。
首先,MySQL的/*! */
符号允许你添加代码的MySQL会服从,但其他数据块会忽略,例如:
create table Users (
id bigint not null auto_increment,
name varchar(40)
) /*! engine=InnoDB */
这不是灵丹妙药,但它会让你纸了一些MySQL和H2的语法之间的区别。这是一个MySQL-ism,所以它不会帮助其他数据库,但是由于大多数其他数据库不像MySQL那样古怪,您可能不需要它 - 我们将数据库从MySQL迁移到PostgreSQL,而不是支持/*! */
表示法,但PostgreSQL与H2相似,我们不需要它。
如果你想为dev和prod使用不同的配置,你可能最好有prod的额外配置。原因是你可能会用play run
启动你的dev服务器,并用play stage; target/start
启动你的prod服务器。 target/start
可以采用-Dconfig.resource
参数。例如,创建一个额外的配置文件prod.conf
的督促,看起来像:
include "application.conf"
# Extra config for prod - this will override the dev values in application.conf
db.default.driver=...
db.default.url=...
...
,并创建一个start_prod
脚本,看起来像:
#!/bin/sh
# Optional - you might want to do this as part of the build/deploy process instead
#play stage
target/start -Dconfig.resource=prod.conf
从理论上讲,你可以轮做它的其他方式,并有application.conf
包含prod conf,并创建一个dev.conf
文件,但是您可能需要一个脚本来启动prod(您可能最终需要额外的JVM /内存/ GC参数,或将其添加到rc.d , 管他呢)。
P.S.刚刚发现:http://play.lighthouseapp.com/projects/82401/tickets/981-overriding-configuration-for-tests状态'wontfix' – biesior 2013-04-15 14:05:49
谢谢。这解释了它。 – 2013-04-15 18:23:39