我正在使用spring dev工具自动在源文件中重新加载我的webapp uppon更改。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
这就是问题。为了执行热重装,Spring会加载并监视项目的所有资源和类,
RestartClassLoader而库(依赖项,例如Drools&Optaplanner)则由base
ClassLoader加载(实际上是
AppClassLoader)。因此存在问题。
要解决此问题,请配置spring dev工具以将Reools库文件连同项目的类一起加载到RestartClassLoader中: using-boot-
devtools-customizing-classload
所以我的问题不是很好的名字。Drools的工作内存不是空的,而是包含不是
instanceof我的类的对象,因为它们不在同一个ClassLoader中。
为了理解这一点,我使用了以下规则:
rule "countProblemFacts"when $nLectures : Long() from accumulate($lectures : Lecture(), count( $lectures )) $nCourses : Long() from accumulate($courses : Course(), count( $courses )) $nRooms : Long() from accumulate($rooms : Room(), count( $rooms )) $nPeriods : Long() from accumulate($periods : Period(), count( $periods )) $nObjects : Long() from accumulate($objects : Object(), count( $objects ))then DroolsUtil.log(drools, "Drools working memory"); DroolsUtil.log("Lectures:", $nLectures); DroolsUtil.log("Courses:", $nCourses); DroolsUtil.log("Rooms:", $nRooms); DroolsUtil.log("Periods:", $nPeriods); DroolsUtil.log("Objects:", $nObjects); DroolsUtil.log(drools, "Total", ($nLectures + $nCourses + $nRooms + $nPeriods), "objects");end$ nObjects计数为12,所有其他计数为0,因为类不是“相同的”。



