Migrating Spring drools-context.xml from 5.0 to 6.0

前端 未结 1 2001
广开言路
广开言路 2021-01-27 06:17

In drools 6, there have been some changes to the Spring integration, such that the resources are no longer specified.

    
        

        
相关标签:
1条回答
  • 2021-01-27 06:21

    Note that in Drools 6, drl files to be loaded should be placed under main/resources folder in your maven project. During runtime say in Tomcat, drl files will appear under <yourwebapp>/WEB-INF/classes folder.

    Sample xml config:

    <?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>
    

    Instead of drools-spring artifact use kie-spring. something like:

    <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>
    
    0 讨论(0)
提交回复
热议问题