【问题标题】:Drools 7 with CDI using Weld带有 CDI 的 Drools 7 使用 Weld
【发布时间】:2017-08-25 07:22:05
【问题描述】:

我已经成功地使用 6.3.0.Final 版本、CDI 1.2 版本和 Weld 2.30.Final 版本运行带有 CDI 的 Drools。使用下面的代码示例。

https://github.com/Salaboy/drools-workshop/tree/master/my-first-drools-project

 public class App {

    @Inject
    @KSession
    private KieSession kSession;

    public void bootstrapDrools() {
        // The KieSession was injected so we can use it now
        kSession.insert("Hi There!");
        int rulesFired = kSession.fireAllRules();
        System.out.println(">>> Rules Fired: "+rulesFired);


    }

    public static void main(String[] args) {
        //Boostrap the CDI container, in this case WELD
        Weld w = new Weld();

        WeldContainer wc = w.initialize();
        App app = wc.select(App.class).get();
        app.bootstrapDrools();

        w.shutdown();
    }
}

现在我正在尝试使用 drools 7.2.0 final 做同样的事情。

但我无法让它工作。有什么想法吗?

【问题讨论】:

    标签: cdi drools weld


    【解决方案1】:

    正如我在博文中的回答 您需要在 drools 7 中添加以下依赖项以使这些示例正常工作: org.drools 流口水-cdi ${kie.version}

    【讨论】:

    • 像魅力一样工作!
    • 耶!太好了,你设法让它工作..如果你能将 PR 发送到我的存储库,这样其他人可以从这个变化中受益,那就太好了:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-19
    • 2021-06-12
    • 1970-01-01
    • 2016-02-14
    • 2011-09-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多