Drools HelloWorld 示例应用程序出错

Drools HelloWorld sample application gives error

当我第一次设置示例 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 规则引擎的新手,我正确地遵循了所有步骤。

是的,最可能的解释是您遗漏了一些相关性。

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

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

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

org.kie.api.runtime.rule.RuleContext

和 kie-api 依赖关系。

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