Drools Project - NeverGiveUp143/Drools GitHub Wiki

Creating a Sample Drool Project

Here we are going to build a sample Drools project using maven dependencies, and this will not require any pre-setup of drools in your eclipse to build the project.

In the sample demo project, we will be creating a Maven Project in which with the help of drools we will decide what discount is to be offered on which Bank Card

So let's follow the below steps to build the Maven Drools Project

Open the eclipse and go to File -> New -> Project

One window will open search for Maven -> Maven Project

image

Click next until you get the “Enter a group id for the artifact.” Page

image

Enter Artifact Id as “DroolsDemo”, Group Id as “com.demo” and click Finish

After clicking on Finish project will be created. Now, Expand the project and open the pom.xml

Under the dependencies tag, add below dependency


<dependency>
       <groupId>org.drools</groupId>
       <artifactId>drools-compiler</artifactId>
       <version>6.0.1.Final</version>
</dependency>

Create a Java class

image

Create a folder resources/META-INF/rules add a drl file in it

image

add Kmodule.xml inside META-INF folder the Kmodule.xml is used to read the drl file

image

add the below code in your main application.java

image

and run the application. Below is the Output

image

Below is the GitHub link to code

https://github.com/NeverGiveUp143/Drools/tree/WorkingExample/SampleProject

⚠️ **GitHub.com Fallback** ⚠️