【问题标题】:Drools HelloWorld sample application gives errorDrools HelloWorld 示例应用程序给出错误
【发布时间】:2016-08-25 05:25:15
【问题描述】:

当我第一次设置示例 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 rule-engine


    【解决方案1】:

    是的,最可能的解释是您遗漏了一些依赖项。

    例如,您需要包含 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 库不在构建路径中。

    【讨论】:

    • Drools 库在构建路径中,drools-core 的依赖项也已添加到 pom.xml(如果它是正确的方法)。我仍然得到相同的编译错误
    • 如果 Drools 库存在,则不需要添加依赖项 drools-core,因为它已经存在。也许与库和您的 Maven 依赖项存在一些冲突。另外既然是编译错误和hello world项目,你定义了drools运行时吗?
    • 是的,我已经定义了一个 drools 运行时,在编写方言后,代码编译并给出静态绑定日志错误/警告并执行 helloworld
    • 程序执行没有错误吧?而且您确实在控制台中打印了消息,不是吗? SLF4J:无法加载类“org.slf4j.impl.StaticLoggerBinder”。 SLF4J:默认为无操作 (NOP) 记录器实现 SLF4J:有关详细信息,请参阅 slf4j.org/codes.html#StaticLoggerBinder。那是错误吗?如果是,您的程序 ideed 执行(编译和运行正确)并且您根本没有实现 slf4j(日志记录)实现。
    猜你喜欢
    • 2013-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-28
    • 1970-01-01
    • 2012-04-27
    • 1970-01-01
    相关资源
    最近更新 更多