我刚开始流口水,我试图运行你好世界,但它一直给我这个错误
packageBuilder中存在一些错误,无法解析ObjectType“Messagee”:[规则名称='Hello World']
Exception in thread "main" java.lang.IllegalArgumentException: Could
not parse knowledge.
at hellodrools.HelloWorldRuleTest.initialiseDrools(HelloWorldRuleTest.java:55)
at hellodrools.HelloWorldRuleTest.main(HelloWorldRuleTest.java:26)
规则编译错误:[规则名称='Hello World']hellodrools/消息/Rule_Hello_World720710180.java(1:8):包hellodrools。消息与类型冲突
我的drl文件:
package hellodrools.Message
rule 'Hello World'
when
message:Message (type == 'Hello')
then
message.printMessage();
end
消息Java语言
package hellodrools;
public class Message{
private String type;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public void printMessage() {
System.out.println("Type: " + type);
}
}
HelloWorldTestRule.java
package hellodrools;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.drools.core.RuleBase;
import org.drools.core.RuleBaseFactory;
import org.drools.core.StatefulSession;
import org.drools.compiler.compiler.DroolsParserException;
import org.drools.compiler.compiler.PackageBuilder;
import org.drools.compiler.compiler.PackageBuilderErrors;
import hellodrools.Message;
public class HelloWorldRuleTest {
private static RuleBase rbase = RuleBaseFactory.newRuleBase();;
private static PackageBuilder pbuilder = new PackageBuilder();
private static StatefulSession sessionObject;
private static String DRL_FILE = "/helloWorld.drl";
public static void main(String[] args) {
initialiseDrools();
initiliseMessageObject();
runRules();
}
// Method to initialise the package builder and add package to the rule
// base.
private static void initialiseDrools() {
// 1. Read the DRL File and add to package builder
try {
Reader reader = new InputStreamReader(
HelloWorldRuleTest.class.getResourceAsStream(DRL_FILE));
pbuilder.addPackageFromDrl(reader);
} catch (DroolsParserException ex) {
Logger.getLogger(HelloWorldRuleTest.class.getName()).log(
Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(HelloWorldRuleTest.class.getName()).log(
Level.SEVERE, null, ex);
}
// 2. Check for any errors
PackageBuilderErrors errors = pbuilder.getErrors();
if (errors.getErrors().length > 0) {
System.out.println("Some errors exists in packageBuilder");
for (int i = 0; i < errors.getErrors().length; i++) {
System.out.println(errors.getErrors()[i]);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
// 3. Add package to rule base
try {
rbase.addPackage(pbuilder.getPackage());
} catch (Exception e) {
System.out.println("Error: " + e);
}
}
// Method to insert message object in session
private static void initiliseMessageObject() {
Message msg = new Message();
msg.setType("Hello");
sessionObject = rbase.newStatefulSession();
sessionObject.insert(msg);
}
// Method to fire all rules
private static void runRules() {
sessionObject.fireAllRules();
}
}
尝试更改包hellodrools。发送给hellodrools包的消息
将message:message(type==“Hello”)修改为message:hellodrools。消息(类型==“Hello”)
关于Eclipse IDE(Indigo、Juno和Kepler(32和64位版本)) 平台:Windows、Ubuntu、Mac M2E版本:1.1.0.20120530-0009,1.2.0.20120903-1050,1.3.0.20130129-0926, 1.4.0.20130601-0317 上面的错误是在将m2e更新到1.1版之后出现的。通过删除M2E1.1并回滚到M2E1.0,一切
尝试fAuth=FirebaseAuthException时出错。getInstance();
问题内容: 我正在将样式加载器与webpack和react框架一起使用。当我在终端中运行webpack时,尽管我已正确指定了文件路径,但我仍获取import.js文件。 webpack.config.js: 问题答案: 尝试在下面运行脚本: 修改webpack配置,在中添加字段。
相反,马文没有做到这一点。。 …在项目中的每个类类型上(不仅仅是上面提到的)。 如何将IntelliJ配置为成功? [与此类似,但不完全相同的问题(尽管可能有帮助)]: 为什么这么红?IntelliJ似乎认为每个声明/方法都无法找到/解决 听起来像是[错误?]的措辞,“导入时无法解析符号”与我的类似,但不同(“无法解析java.lang.Object类型。它是从必需的.class文件中间接引用的”
我想使用Eclipse Indigo运行maven项目,但当我运行项目Run As- 我对此进行了研究,后来意识到slf4j依赖也缺失了。我下载了slf4j-1.7.5.zip并将以下文件提取到C:\Program files\Java\jdk1.7.0\u 17\lib中: slf4j-simple-1.7.5.jarslf4j-api-1.7.5.jarlog4j-over-slf4j-1.7