我有以下课程
public class SeniorClass {
List<Students> stud;
String highScorerMath;
String highScorerChemistry;
String highScorerPhysics;
String highScorerEnglish;
int studentPassCount=2;
public String getHighScorerMath() {
return highScorerMath;
}
public void setHighScorerMath(String highScorerMath) {
this.highScorerMath = highScorerMath;
}
public String getHighScorerChemistry() {
return highScorerChemistry;
}
public void setHighScorerChemistry(String highScorerChemistry) {
this.highScorerChemistry = highScorerChemistry;
}
public String getHighScorerPhysics() {
return highScorerPhysics;
}
public void setHighScorerPhysics(String highScorerPhysics) {
this.highScorerPhysics = highScorerPhysics;
}
public String getHighScorerEnglish() {
return highScorerEnglish;
}
public void setHighScorerEnglish(String highScorerEnglish) {
this.highScorerEnglish = highScorerEnglish;
}
public int getStudentPassCount() {
return studentPassCount;
}
public void setStudentPassCount(int studentPassCount) {
this.studentPassCount = studentPassCount;
}
public List<Students> getStud() {
return stud;
}
public void setStud(List<Students> stud) {
this.stud = stud;
}
}
当我将与此类相关的数据插入Drools会话和触发规则时。以下规则似乎不起作用。
rule "Students passed count"
lock-on-active true
dialect "mvel"
dialect "java"
salience 0
when
$sc : SeniorClass(studentPassCount > 0);
then
System.out.println(" Rule 6: Total no. of Students passed are: " + $sc.getStudentPassCount());
end
我不确定为什么我的条件检查&#34; studentPassCount&gt; 0&#34;即使在课堂上我已将此变量值设置为2,也不会变为真实。任何人都可以建议我解决这种情况。
答案 0 :(得分:1)
您是否将类SeniorClass的事实插入到工作记忆中?
您确定没有使用&lt; = 0?
的值调用setStudentPassCount吗?规则库中是否还有其他规则将lock-on-active设置为true? 我强烈建议您不要使用此属性,除非没有别的办法。
您确定规则在语法上是正确的,以便规则库包含此规则(以及其他规则)吗?
你有没有给fireAllRules打电话? (您是否注意到其他规则会被解雇?)
为什么要为dialect
使用矛盾的规则属性值? 坚持其中一个。