我们有一个使用Drools规则的旧版Java / Spring项目。有什么方法可以在IntelliJ上调试规则文件,例如添加断点和逐步执行规则逻辑?
最佳答案
Toni点是有效的(Idea插件不允许调试实际的Drools规则),但请注意,可以在Drools角色调用的实际Java方法上设置断点。下面的代码片段会有所帮助(isRuleApplicable和getAttribute是实际的Java方法):
//salience allows to give rules a priority
rule "Number of adults in the family" salience 10
when
// condition on eligible is required to avoid endless loop
stbFact: Stb()
eval(stbFact.getEligible() == null && stbFact.isRuleApplicable("Number of adults in the family") && stbFact.getAttribute("enh_000010", "1", "5"))
then
System.out.println("[Number of adults in the family] Drools Rule has been satisfied (debug purposes)!!!");
stbFact.setEligible(Boolean.TRUE);
update( stbFact );
end