java Drools hello world Maven 依赖项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11872328/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 06:44:42  来源:igfitidea点击:

Drools hello world maven dependencies

javamavendependenciesdrools

提问by Leonti

I'm trying to run very simple application using Drools and for a couple of hours now can't set up pom.xml with all dependencies.

我正在尝试使用 Drools 运行非常简单的应用程序,现在有几个小时无法使用所有依赖项设置 pom.xml。

Here is how it looks now:

这是它现在的样子:

    <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>

Just like in https://community.jboss.org/wiki/DroolsMaven

就像在 https://community.jboss.org/wiki/DroolsMaven

But what I get:

但我得到的是:

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

If I try to add Janino I get another exception about some missing classes(I don't think I should add Janino here anyway as it should be a dependency of something else). Do I miss anything in my pom?

如果我尝试添加 Janino,我会得到另一个关于某些缺失类的异常(我认为无论如何我都不应该在这里添加 Janino,因为它应该是其他东西的依赖项)。我错过了我的 pom 中的任何东西吗?

Thanks!

谢谢!

Leonty

莱昂蒂

回答by Geoffrey De Smet

By default, drools-compiler uses the eclipse compiler (JavaDialectConfiguration.ECLIPSE) for the java dialect which is a transitive dependency:

默认情况下,drools-compilerJavaDialectConfiguration.ECLIPSE对 java 方言使用 eclipse 编译器 ( ) ,它是一个传递依赖项:

<dependency>
  <groupId>org.eclipse.jdt.core.compiler</groupId>
  <artifactId>ecj</artifactId>
</dependency>

However, if you prefer the janino compiler(JavaDialectConfiguration.JANINO), you need to add the janino dependency yourself because it is an optional transitive dependency:

但是,如果您更喜欢 janino 编译器( JavaDialectConfiguration.JANINO),则需要自己添加 janino 依赖项,因为它是一个可选的传递依赖项:

<dependency>
  <groupId>org.codehaus.janino</groupId>
  <artifactId>janino</artifactId>
  <optional>true</optional>
</dependency>

Look at the droolsjbpm-parent pom to find out which version to use.

查看 droolsjbpm-parent pom 以找出要使用的版本。

回答by Leonti

Turned out just the right version of Janino is needed for Drools 5.4.0 Final: 2.5.16Newer versions luck class used in Drools.

结果证明 Drools 5.4.0 Final 需要正确版本的 Janino:2.5.16Drools 中使用的较新版本运气类。

<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>