Drools HelloWorld示例应用程序出错

时间:2016-08-25 05:25:16

标签: drools rule-engine

当我第一次设置示例hello world应用程序时,我在rules/sample.drl文件中出现错误

错误如下:

Rule Compilation error Only a type can be imported. com.sample.DroolsTest.Message resolves to a package
Only a type can be imported. org.drools.core.spi.KnowledgeHelper resolves to a package
KnowledgeHelper cannot be resolved to a type
com.sample.DroolsTest.Message cannot be resolved to a type
org.kie.api.runtime.rule.FactHandle cannot be resolved to a type
org.kie.api.runtime.rule.FactHandle cannot be resolved to a type
java.lang.Exception cannot be resolved to a type
org.kie.api.runtime.rule.RuleContext cannot be resolved to a type
Message.GOODBYE cannot be resolved to a type
org.drools.core.util.bitmask.AllSetBitMask cannot be resolved to a type
com.sample.DroolsTest.Message cannot be resolved to a type

我写dialect "mvel"时也修正了错误 但由于某种原因,我对这个快速解决方案不满意。

我错过了一些插件或依赖项吗? 我是drools规则引擎的新手,我正确地遵循了所有步骤。

1 个答案:

答案 0 :(得分:1)

是的,最可能的解释是你错过了一些依赖。

您需要包含drools-core,例如:

Only a type can be imported. org.drools.core.spi.KnowledgeHelper resolves to a package

建议规则无法访问KnowledgeHelper并尝试将其作为包导入。 同样的事情发生在:

org.kie.api.runtime.rule.RuleContext

和kie-api依赖。

如果您使用Eclipse或其他IDE并启动了一个新的drools项目,那么drools库可能不在构建路径中。