2017-08-28 103 views
1

下面的代碼不能被編譯由於「找不到符號 符號:類aNewRulesEngine 位置:類org.jeasy.rules.core.RulesEngineBuilder」簡單的規則:無法解析aNewRulesEngine()

然而,判斷通過本教程https://github.com/j-easy/easy-rules/wiki/fizz-buzz它應該沒問題。

任何想法爲什麼它會變酸?

import org.jeasy.rules.api.RulesEngine; 
import org.jeasy.rules.core.RulesEngineBuilder; 

public class Main { 

    public static void main(String[] args) { 
     RulesEngine rulesEngine = new RulesEngineBuilder.aNewRulesEngine(); 
    } 
} 
+4

刪除'new'關鍵字... –

回答

1

aNewRulesEngine是RulesEngineBuilder一個靜態方法(根據文檔:https://github.com/j-easy/easy-rules/blob/master/easy-rules-core/src/main/java/org/jeasy/rules/core/RulesEngineBuilder.java) - 但你的代碼示例中,你也試圖實例化RulesEngineBuilder一個實例。

也許這代碼將更好的工作:

import org.jeasy.rules.api.RulesEngine; 
import org.jeasy.rules.core.RulesEngineBuilder; 

public class Main { 

    public static void main(String[] args) { 
     RulesEngine rulesEngine = RulesEngineBuilder.aNewRulesEngine(); 
    } 
} 
+1

謝謝你很多。愚蠢的錯字... – Adam

+1

沒問題,它發生了。很高興我能幫上忙 :-) – Assafs