使用kmodule.xml找不到KieBase的DRL文件 [英] No DRL files found for the KieBase, using kmodule.xml

查看:248
本文介绍了使用kmodule.xml找不到KieBase的DRL文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java和Drools 6.2.0开发Maven项目,并且试图通过kmodule.xml文件将某个DRL文件绑定到KieBase,但是我一直收到错误消息

I'm developing a Maven project using java and Drools 6.2.0, and I'm trying to "bind" a certain DRL file to a KieBase through the kmodule.xml file, but I keep getting the error

WARN org.drools.compiler.kie.builder.impl.AbstractKieModule - No files found for KieBase

在运行项目时。

我认为我已经正确配置了所有内容,如文档(第4.2.2章-概述-构建,部署,使用和运行-构建),但看不到我的错误在哪里。

I think I've configured everything the right way, as shown in the documentation (Chapter 4.2.2 - Overview - Build, Deploy, Utilize and Run - Building), but can't see where is my mistake.

在这个项目中,由于项目的体系结构,我认为通过编码声明/配置Drools不是我的选择,这就是为什么我使用kmodule.xml方法的原因。

In this project, I think it's not an option for me to declare/configure Drools by coding, due to the project architecture, that's why I'm using the kmodule.xml approach.

欢迎任何建议。

我的kmodule.xml(位置:s rc / main / resources / META-INF):

My kmodule.xml (location: src/main/resources/META-INF):

<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://jboss.org/kie/6.0.0/kmodule">
    <kbase name="departureKB" packages="com.site.myapp.checks.departure">
        <ksession name="departureKS" type="stateless" />
    </kbase>
</kmodule>

我的DRL文件(虚拟)(位置:src / main / resources / com / site / myapp /检查/出发):

My DRL file (dummy) (location: src/main/resources/com/site/myapp/checks/departure):

package com.site.myapp.checks.departure

rule "my rule 1"
    when
        // some conditions
    then
        // something to do
end

我的班级出发(仅Drools代码)(位置:src / com / site / myapp / checks):

My class Departure (only the Drools code) (location: src/com/site/myapp/checks):

channelName = "departure";
KieServices ks = KieServices.Factory.get();
KieContainer kc = ks.getKieClasspathContainer();
String kSessionName = channelName+"KS";
kSession = kc.newStatelessKieSession(kSessionName);

我的pom.xml(仅Drools依赖项):

My pom.xml (only the Drools dependencies) :

<dependency>
    <groupId>org.drools</groupId>
    <artifactId>drools-bom</artifactId>
    <version>6.2.0.Final</version>
    <type>pom</type>
</dependency>
<dependency>
    <groupId>org.kie</groupId>
    <artifactId>kie-api</artifactId>
    <version>6.2.0.Final</version>
</dependency>
<dependency>
    <groupId>org.drools</groupId>
    <artifactId>drools-compiler</artifactId>
    <version>6.2.0.Final</version>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>org.drools</groupId>
    <artifactId>named-kiesession</artifactId>
    <version>6.2.0.Final</version>
</dependency>


推荐答案

问题是需要在 pom.xml 文件以包含DRL文件。

The problem is that it's needed to declare in the pom.xml file to include the DRL files.

pom.xml 文件应如下所示(在我的项目,就像这样,其他项目应该与此类似)。

The pom.xml file should look like this (in my project it's like this, should be similar in others):

<project ...>
   ...
    <build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>META-INF/kmodule.xml</include>
                    <include>com/site/myapp/checks/departure/Departure.drl</include>
                </includes>
                <targetPath>.</targetPath>
            </resource>
        </resources>
    </build>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.drools</groupId>
                <artifactId>drools-bom</artifactId>
                <version>6.2.0.Final</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-compiler</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
</project>

请注意,其中涉及与pom.xml相关的更改问题。

在这里,我更改了 drools-bom 工件的位置,它现在位于 dependecyManagement 中标记(此工件用于工件的版本控制,使用此工件,您只需一次声明工件的版本);并删除了 named-kiesession 工件。

Take notice to the changes related with the pom.xml indicated in the Question.
Here, I've changed the location of the drools-bom artifact, it's now in the dependecyManagement tag (this artifact is used for the version control of the artifacts, with this you only need to declared the version of the artifacts one time); and have removed the named-kiesession artifact.

这篇关于使用kmodule.xml找不到KieBase的DRL文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆