0

我在我的口水文件中写了下面的部分。我没有收到任何编译错误,但它没有在运行时执行。我们可以从流口水的属性文件中读取数据,还是我们有任何替代方法可以从配置文件中读取数据。你能帮我解决这个问题吗?

Drool 中添加的一段代码:

InputStream fileInput = Thread.currentThread().getContextClassLoader().getResourceAsStream("rules.properties");
Properties properties = new Properties();
System.out.println("Client From Properties : "+fileInput);
properties.load(fileInput);
fileInput.close();
4

1 回答 1

1

您是否在不同的 java 类中编写了该代码片段并通过口水调用它?

  1. 在名为 Test.java 的类中编写代码:

    public class Test { public static void testFileRead(){ //你的代码 } }

  2. 在 .drl 文件中导入该函数,

    导入函数Test.testFileRead;

  3. 在规则的“然后”部分执行方法

    然后

        testFileRead();
    
于 2017-01-11T03:12:14.937 回答