java 配置 drools 和 maven 并使用它们编写 hello world 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5402053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Configuring drools and maven and writing hello world application using them
提问by Anupam Gupta
I want to learn drools and maven can any one help me with the links for configuring drools and maven and writing a basic hello world example using them.
我想学习drools和maven,任何人都可以帮助我配置drools和maven的链接,并使用它们编写一个基本的hello world示例。
Thanks in advance
提前致谢
回答by John Manak
You should first read the manual, then try google it. There have also been questions like this asked before, for example: How to deploy Drools Flow and rules by my web application
你应该先阅读手册,然后尝试谷歌它。之前也有人问过这样的问题,例如:How to deploy Drools Flow and rules by my web application
But anyways. This is how to integrate it if you use Maven and Spring:
但无论如何。如果您使用 Maven 和 Spring,这是如何集成它的:
you first need to include Drools dependencies:
您首先需要包含 Drools 依赖项:
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-spring</artifactId>
<version>${drools.version}</version>
</dependency>
Define the application context:
定义应用上下文:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:drools="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://drools.org/schema/drools-spring http://drools.org/schema/drools-spring.xsd">
<drools:kbase id="kbase1">
<drools:resources>
<drools:resource source="classpath:Sample.drl" />
</drools:resources>
</drools:kbase>
<drools:ksession id="ksession1" type="stateful" kbase="kbase1" />
</beans>
Then you can inject ksession1
as a bean.
然后你可以注入ksession1
一个bean。
回答by Thomas
Try google: First result for Drools Maven Tutorial
: http://www.installationwiki.org/Set_Up_for_JBoss_Drools.
试试谷歌:第一个结果Drools Maven Tutorial
:http: //www.installationwiki.org/Set_Up_for_JBoss_Drools。
Note that Maven is a "build" tool (actually it's more) whereas Drools is a platform/library. So using Drools does normally not depend on Maven. You might thus want to get separate tutorials.
请注意,Maven 是一个“构建”工具(实际上它更多),而 Drools 是一个平台/库。所以使用 Drools 通常不依赖于 Maven。因此,您可能希望获得单独的教程。