我想对我的数据库操作进行单元测试,然后找到了this code。但是,我收到了以下错误:
[CityGame] $ test
[info] Compiling 2 Java sources to /Users/pmichna/Documents/code/citygame/target/scala-2.10/test-classes...
[error] /Users/pmichna/Documents/code/citygame/test/models/BaseModelTest.java:31: error: constructor DdlGenerator in class DdlGenerator cannot be applied to given types;
[error] ddl = new DdlGenerator((SpiEbeanServer) server, new MySqlPlatform(), config);
[error] ^
[error] required: no arguments
[error] found: SpiEbeanServer,MySqlPlatform,ServerConfig
[error] reason: actual and formal argument lists differ in length
[error] 1 error
[error] (test:compile) javac returned nonzero exit code
[error] Total time: 2 s, completed 2013-12-17 00:21:23
DdlGenerator
的实施是否已更改?
答案 0 :(得分:7)
是的,实施已经改变。构造函数不带参数,而是应该使用setup()
方法。这导致了这样的事情:
EbeanServer server = Ebean.getServer(serverName);
ServerConfig config = new ServerConfig();
DdlGenerator ddl = new DdlGenerator();
ddl.setup((SpiEbeanServer) server, new MySqlPlatform(), config);