我是Drools的新手;我正在尝试通过示例学习Drools,但是我的设置似乎有问题,因为我无法成功运行我的应用。
这是我的规则:
package com.example.rules
import newexample.Person;
rule "Is of valid age"
when
$p : Person( age < 18 )
then
$p.setValid( false );
end
并设置:
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
<kbase name="rules" packages="rules">
<ksession name="ksession-rule"/>
</kbase>
</kmodule>
当我尝试运行我的应用程序时,出现此错误:
... - Adding Service org.drools.compiler.kie.builder.impl.KieServicesImpl
... - Adding Service org.drools.compiler.builder.impl.KnowledgeBuilderFactoryServiceImpl
... - Found kmodule: file:/.../poc-drools/target/scala-2.12/test-classes/META-INF/kmodule.xml
... - KieModule URL type=file url=/.../poc-drools/target/scala-2.12/test-classes
... - Unable to find pom.properties in /.../poc-drools/target/scala-2.12/test-classes
... - As folder project tried to fall back to pom.xml, but could not find one
... - Unable to load pom.properties from/.../poc-drools/target/scala-2.12/test-classes
... - Cannot find maven pom properties for this project. Using the container's default ReleaseId
... - Discovered classpath module org.default:artifact:1.0.0
... - KieModule was added: FileKieModule[releaseId=org.default:artifact:1.0.0,file=/.../poc-drools/target/scala-2.12/test-classes]
... - File 'rules/1th.drl' is in folder 'rules' but declares package 'com.example.rules'. It is advised to have a correspondance between package and folder names.
... - Unable to build KieBaseModel:defaultKieBase
Rule Compilation error : [Rule name='Is of valid age']
com/example/rules/Rule_Is_of_valid_age734850681.java (1:0) : The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
com/example/rules/Rule_Is_of_valid_age734850681.java (1:0) : The type java.io.Serializable cannot be resolved. It is indirectly referenced from required .class files
com/example/rules/Rule_Is_of_valid_age734850681.java (3:136) : Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor
com/example/rules/Rule_Is_of_valid_age734850681.java (6:369) : java.lang.Exception cannot be resolved to a type
我正在使用Scala 2.13,SBT 1.2.6,JVM 1.8和MacOS
我已经用sdkamn
安装了JVM。
当我使用Maven初始化项目时,一切正常!但是用sbt我得到提到的错误。
答案 0 :(得分:0)
看来,当我包含Drools
的应用程序与JVM
在同一SBT
进程中运行时,它遇到了可用类和类路径的问题!
我没有弄清楚真正的原因,但是当我配置项目以在单独的JVM进程中运行应用程序时,它起作用了:
fork := true