2013-12-16 505 views
3

我想單元測試我的數據庫操作,我發現this code。但是,我得到以下錯誤:DdlGenerator構造函數不需要參數?

[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已更改?

回答

7

是的,實施已經改變。構造函數沒有參數,但應該使用setup()方法。這導致這樣的事情:

EbeanServer server = Ebean.getServer(serverName); 
ServerConfig config = new ServerConfig(); 
DdlGenerator ddl = new DdlGenerator(); 
ddl.setup((SpiEbeanServer) server, new MySqlPlatform(), config); 
+0

謝謝!你在哪裏找到這些信息?我通過Ebean JacaDoc看了一眼,什麼都沒有...... – pmichna

+1

我看了看遊戲的源代碼。它使用'DdlGenerator'來啓動演化腳本。看到這裏:https://github.com/playframework/playframework/blob/master/framework/src/play-java-ebean/src/main/java/play/db/ebean/EbeanPlugin.java#L114 – mguillermin

相關問題