Drools规则文件中的注释出错

今天写了一段drools规则脚本,一直出错,多次调试终于找到原因,是因为drools不能在{}体内是用“//”写注释,如:

        /*
        	计算10:
        If CURRENT_DATE in (当年的0101-0430含) then
        Corp_quar_date_1=上年最后一天
        Corp_quar_date_2=上上年最后一天
        */
        int monthDay = monthDay($a.data_date);
        log.debug("monthDay = {}", monthDay);
        if (monthDay <= 430) {
//            If CURRENT_DATE in (当年的0101-0430含) then Corp_quar_date_1=上年最后一天 Corp_quar_date_2=上上年最后一天
            $a.corp_quar_date_1 = (Integer.parseInt($a.data_date.substring(0,4)) -1)  + "1231";
            $a.corp_quar_date_2 = $a.corp_quar_date_1;
        } else {
           //CURRENT_DATE in (当年的1101-1231含) then  Corp_quar_date_1=当年930 Corp_quar_date_2=当年930
           $a.corp_quar_date_1 = $a.data_date.substring(0,4) + "0930";
           $a.corp_quar_date_2 = $a.corp_quar_date_1;
        }
        log.debug("$a.corp_quar_date_1 = {}, corp_quar_date_2={}", $a.corp_quar_date_1, $a.corp_quar_date_2);

加载这个规则会一直报错:


        log.trace("6)	��˾Ͷ�ʼ��ж� -----");:
[Error: unbalanced braces { ... }]
[Near : {... f (monthDay <= 430) {//            If CURRENT_DATE ....}]
                                 ^
[Line: 22, Column: 0] : [Rule name='ExposurePre_COMP']

意思是说,花括号“{ }” 不对称。
研究了半天才发现,在花括号“{ }”语句块里面不能使用"//"写注释,改成“/* */” 就好了。修改成下面示例就好了:

        /*
        	计算10:
        If CURRENT_DATE in (当年的0101-0430含) then
        Corp_quar_date_1=上年最后一天
        Corp_quar_date_2=上上年最后一天
        */
        int monthDay = monthDay($a.data_date);
        log.debug("monthDay = {}", monthDay);
        if (monthDay <= 430) {
            /*If CURRENT_DATE in (当年的0101-0430含) then Corp_quar_date_1=上年最后一天 Corp_quar_date_2=上上年最后一天*/
            $a.corp_quar_date_1 = (Integer.parseInt($a.data_date.substring(0,4)) -1)  + "1231";
            $a.corp_quar_date_2 = $a.corp_quar_date_1;
        } else {
           /*CURRENT_DATE in (当年的1101-1231含) then  Corp_quar_date_1=当年930 Corp_quar_date_2=当年930*/
           $a.corp_quar_date_1 = $a.data_date.substring(0,4) + "0930";
           $a.corp_quar_date_2 = $a.corp_quar_date_1;
        }
        log.debug("$a.corp_quar_date_1 = {}, corp_quar_date_2={}", $a.corp_quar_date_1, $a.corp_quar_date_2);

具体点,错误的写法:

//这个可以
if (a < 1) {
	//这里不行
	log.debug("true);
}

正确的写法:

//这个可以
if (a < 1) {
	/*这样注释就对了*/
	log.debug("true);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值