在 drools 6 中, Spring 集成发生了一些变化,不再指定资源。
<drools:resources>
<drools:resource type="DRL"
source="classpath:rules/products.drl"/>
</drools:resources>
那么如何在版本 6 中指定它们呢?
在 drools 6 中, Spring 集成发生了一些变化,不再指定资源。
<drools:resources>
<drools:resource type="DRL"
source="classpath:rules/products.drl"/>
</drools:resources>
那么如何在版本 6 中指定它们呢?
请注意,在 Drools 6 中,要加载的 drl 文件应放在 maven 项目的 main/resources 文件夹下。在 Tomcat 中运行时,drl 文件将出现在 <yourwebapp>/WEB-INF/classes 文件夹下。
示例 xml 配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:kie="http://drools.org/schema/kie-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://drools.org/schema/kie-spring http://drools.org/schema/kie-spring.xsd">
<kie:kmodule id="kmoduleCEP">
<kie:kbase name="kbaseCEP" eventProcessingMode="stream"
equalsBehavior="equality">
<kie:ksession name="ksessionCEP" type="stateful"
clockType="realtime">
<kie:agendaEventListener ref="agendaEventListener" />
<kie:ruleRuntimeEventListener ref="workingMemoryEventListener" />
<kie:batch>
<kie:set-global identifier="callbackService">
<ref bean="callbackService" />
</kie:set-global>
</kie:batch>
</kie:ksession>
</kie:kbase>
</kie:kmodule>
</beans>
使用 kie-spring 代替 drools-spring 神器。就像是:
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-spring</artifactId>
<version>${org.drools.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${org.drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${org.drools.version}</version>
</dependency>