问题描述
我正在获取示例,例如如何在eclipse或其他IDE中安装drools插件。但是,如何在不使用Eclipse之类的IDE的情况下配置流口水。
I am getting example like how to install drools plugins in eclipse or other IDE. But how can I configure drools without using any IDE like eclipse.
推荐答案
-
Maven项目(使用您喜欢的IDE或命令行)
Create a Maven Project (using your favorite IDE or the comand-line)
将Drools编译器功能和一些日志记录兼容的库添加到pom.xml中(Maven主项目文件):
Add Drools Compiler depedency and some logging compatible library to your pom.xml (main Maven project file):
<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>6.3.0.Final</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.5</version>
</dependency>
</dependencies>
使用以下命令创建src / main / resources / META-INF / kmodule.xml文件内容:
Create the src/main/resources/META-INF/kmodule.xml file with the contents:
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule" />
创建src / main / resources / myrules.drl之类的DRL文件
Create your DRL file like src/main/resources/myrules.drl
rule "hello"
when
$name : String()
then
System.out.println("Hello "+$name);
end
创建基于KieService的代码:
Create your KieService based code:
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
public class Main {
public static void main(String[] args) {
KieServices ks = KieServices.Factory.get();
KieContainer kcontainer = ks.getKieClasspathContainer();
KieSession ksession = kcontainer.newKieSession();
String name="Xeetu";
ksession.insert(name);
ksession.fireAllRules();
}
}
这篇关于如何在没有Eclipse或任何其他IDE的情况下配置流口水的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!