我正在尝试使用Drools运行非常简单的应用程序,现在几个小时都无法设置包含所有依赖项的pom.xml。
以下是现在的样子:
<dependencies>
<!-- Drools engine -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>5.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.4.0.Final</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
</dependencies>
就像在 https://community.jboss.org/wiki/DroolsMaven
但我得到的是:
org.drools.RuntimeDroolsException: Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java:org.drools.rule.builder.dialect.java.JavaDialectConfiguration'
at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:313)
at org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:298)
at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:187)
at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:160)
at org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactoryServiceImpl.java:26)
at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactory.java:85)
yada-yada-yada
Caused by: java.lang.RuntimeException: The Janino jar is not in the classpath
如果我尝试添加Janino,我会得到一些关于某些缺失类的例外(我认为我不应该在这里添加Janino,因为它应该是其他东西的依赖)。 我错过了我的pom中的任何东西吗?
谢谢!
Leonty
答案 0 :(得分:2)
默认情况下,drools-compiler使用eclipse编译器(JavaDialectConfiguration.ECLIPSE
)作为传递依赖的java方言:
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
</dependency>
但是,如果您更喜欢janino编译器(JavaDialectConfiguration.JANINO
),则需要自己添加janino依赖项,因为它是可选的传递依赖项:
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<optional>true</optional>
</dependency>
查看droolsjbpm-parent pom以找出要使用的版本。
答案 1 :(得分:1)
Drools 5.4.0决赛需要正确的Janino版本: 2.5.16 在Drools中使用的较新版本运气类。
<dependencies>
<!-- Drools engine -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>5.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>2.5.16</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
</dependencies>