怎么在项目中引入Spring框架怎么解决
1个回答
展开全部
这段drl规则文件申明并引用了global变量
package com.acme.app.rules
import com.acme.app.form.applicationform
import com.acme.app.model.applicant
import com.acme.app.validation.errors
import com.acme.app.dao.applicantdao
global applicantdao applicantdao
rule "check applicant age"
when
$a : applicationform()
$errors : errors()
$applicant:applicant( age < 18 ) from applicantdao.findapplicant($a.getapplicantid())
then
$errors.adderror( $a, "applicantid", "applicant age < 18" );
end
下面这段java代码是在初始化knowledgesession的过程中,把spring中的bean设置成global变量
statefulknowledgesession ksession = kbase.newstatefulknowledgesession();
ksession.setglobal("applicantdao", applicantdao);
spring中配置bean
<bean id="applicantdao" class="com.acme.app.dao.impl.applicantdaoimpl"></bean>
</beans>
package com.acme.app.rules
import com.acme.app.form.applicationform
import com.acme.app.model.applicant
import com.acme.app.validation.errors
import com.acme.app.dao.applicantdao
global applicantdao applicantdao
rule "check applicant age"
when
$a : applicationform()
$errors : errors()
$applicant:applicant( age < 18 ) from applicantdao.findapplicant($a.getapplicantid())
then
$errors.adderror( $a, "applicantid", "applicant age < 18" );
end
下面这段java代码是在初始化knowledgesession的过程中,把spring中的bean设置成global变量
statefulknowledgesession ksession = kbase.newstatefulknowledgesession();
ksession.setglobal("applicantdao", applicantdao);
spring中配置bean
<bean id="applicantdao" class="com.acme.app.dao.impl.applicantdaoimpl"></bean>
</beans>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询