简体   繁体   中英

Drools cannot resolve a global variable

i'm trying to add String items to a global variable $items. But i get an error "$items cannot be resolved"

Below is snippet of my drl rule. What am i missing?

code snippet

you can try this

First : in drl file

global java.util.HashSet items

rule "rule 1"
    when
    then
        items.add("Item 1");
        System.err.println(items);
end

Second : in java file

KieSession kieSession = ...
kieSession.setGlobal("items",new HashSet<>());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM