Drools不适用于spring-boot-devtools

时间:2019-03-27 09:30:58

标签: drools

当在pom.xml上具有spring-boot-devtools时,drools规则不起作用。没有错误,但是流口水的规则根本没有被解雇。在排除spring-boot-devtools之后,流口水规则开始起作用。

2 个答案:

答案 0 :(得分:1)

确实是一个很奇怪的问题。据我所知,这里有2个问题:

  1. 显然,KieFileSystem在org.springframework.boot.devtools.restart.classloader.RestartClassLoader上不能很好地运行。即使我尝试将DRL作为字符串传递,也没有接受。
  2. 即使我设法使用KieBase文件填充了kmodule.xml,规则仍然没有触发。我的猜测是,类加载器有时会更改类的定义,因此,当您插入Product对象时,其类不再与DRL使用的Product类相同。另一种可能是有多个类加载器在起作用。看看this questionthis document

不幸的是,我无法找到一种使之工作的方法。希望我提供的信息对您有所帮助。

答案 1 :(得分:1)

关于使用spring-boot devtools和drools时的类加载问题,有一个已记录的问题:DROOLS-1540

spring-boot reference documentation中所述,您可以将jar添加到devtools“重新加载”类加载器中,作为解决方法。

META-INF / spring-devtools.properties

restart.include.drools-core=/drools-core-7.0.0.Final.jar
restart.include.drools-compiler=/drools-compiler-7.0.0.Final.jar
restart.include.kie-api=/kie-api-7.0.0.Final.jar
restart.include.kie-ci=/kie-ci-7.0.0.Final.jar
restart.include.kie-internal=/kie-internal-7.0.0.Final.jar

请小心使用您的完全匹配jar,并最终添加直接在您的规则文件中引用的其他库。


(对于主持人)使Drools rule does't working in Spring Boot Controller but working in Junit Test重复此问题,并删除了该帖子的答案