我创建了一个流口水文件 PersonTotalAccountsBalance.drl 如下。我是规则引擎世界的初学者。
package com.auhuman.rules;
import com.auhuman.Person;
import com.auhuman.Account;
function float getTotalBalance(Person person) {
float totalBalance = 0;
for (Account account : person.getAccounts()){
totalBalance += account.getBalance();
}
return totalBalance;
}
rule "PersonTotalAccountsBalance"
when
$node : Person(active == true)
then
float totalBalance = getTotalBalance($node)
modify($node) {
setTotalBalance(totalBalance);
}
end
Run Code Online (Sandbox Code Playgroud)
编译后我收到以下错误
Unable to compile the file: PersonTotalAccountsBalance.drl. Errors = [Unable to find @positional field 0 for class Person
: [Rule name='PersonTotalAccountsBalance']
]
Run Code Online (Sandbox Code Playgroud)
虽然这个问题很老了:我有同样的错误消息,但我正在使用xls(excel)格式的决策表。桌子看起来像这样:
请注意,$order:Order合并单元格中的 is 会跨越 和CONDITION列ACTION。该单元格只允许位于CONDITION表格之上,而不是ACTION表格之上。取消合并后,我不再收到错误:
ACTION在设置属性的列中定义错误的值时,我遇到了非常类似的错误。String当在模型中的属性中使用不带引号的值时,Order出现以下错误:
Unable to get KieModule, Errors Existed: Error Messages:
Message [id=1, kieBase=defaultKieBase, level=ERROR, path=status_rules/status.xls, line=21, column=0
text=Rule Compilation error The method setNextStatus(String) in the type Order is not applicable for the arguments (int)]
Message [id=2, kieBase=defaultKieBase, level=ERROR, path=status_rules/status.xls, line=5, column=0
text=Rule Compilation error The method setNextStatus(String) in the type Order is not applicable for the arguments (int)]
Message [id=3, kieBase=defaultKieBase, level=ERROR, path=status_rules/status.xls, line=13, column=0
text=Rule Compilation error The method setNextStatus(String) in the type Order is not applicable for the arguments (int)]
Run Code Online (Sandbox Code Playgroud)
然而,在这种情况下,错误消息更加准确。