我正在尝试使用SWRLAPI和OWLAPI向我的Ontology添加SWRL规则。我正在尝试使用与SWRLAPI兼容的OWLAPI版本。但是,创建规则时仍然会出错。这似乎是依赖关系管理的一个问题。我使用gradle作为依赖管理器,所以这应该解决了这个问题。
例外情况是:
创建规则引擎Drools时出错。例外:java.lang.NoClassDefFoundError。消息:org / drools / runtime / rule / AgendaFilter“
我的build.gradle依赖文件:
dependencies {
compile group: 'net.sourceforge.owlapi', name: 'owlapi-distribution', version: '4.1.3'
compile group: 'net.sourceforge.owlapi', name: 'org.semanticweb.hermit', version: '1.4.1.513'
compile 'edu.stanford.swrl:swrlapi:2.0.5'
compile 'edu.stanford.swrl:swrlapi-drools-engine:2.0.5'
}
执行createSWRLRuleEngine方法时发生异常:
public void addNewSWRLRule(SWRLRuleModel rule) throws SWRLBuiltInException, SWRLParseException {
SWRLRuleEngine swrlRuleEngine = SWRLAPIFactory.createSWRLRuleEngine(ontology);
swrlRuleEngine.infer();
swrlRuleEngine.createSWRLRule(rule.getName(), rule.getRule(), rule.getComment(), true);
}
是否存在必须手动添加的依赖项才能解决此问题?
你正在使用HermiT 1.4.1.513。这与owlapi 5兼容,而不是4(补丁号与owlapi版本匹配)。使用HermiT 1.3.8.413。
问题是来自Drools Engine(edu.stanford.swrl:swrlapi-drools-engine:2.0.5)的2个maven依赖项无法通过gradle解决。
缺少的依赖项是:
我不确定是什么导致这些不能通过gradle解决,但我设法通过将两个缺少的依赖项转换为存储库并按照以下步骤在maven中搜索这些问题来解决IntelliJ中的问题: