我试图使用SWRLAPI和OWLAPI将SWRL规则添加到本体中。我正在尝试使用与SWRLAPI兼容的OWLAPI版本。然而,在创建规则时,我仍然会遇到错误。这似乎是依赖关系管理的一个问题。我使用gradle作为依赖关系管理器,所以这应该解决了这个问题。
例外是:
创建规则引擎流口水时出错。例外: java.lang.NoClassDefFoundError。消息:org/drools/运行时/规则/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);
}是否必须手动添加依赖关系才能解决此问题?
发布于 2018-09-12 09:59:38
问题是有两个来自Drools引擎(edu.stanford.swrl:swrlapi-drools-engine:2.0.5)的maven依赖关系没有被gradle解决。
缺少的依赖关系是:
我不知道是什么原因导致gradle没有解决这些问题,但我设法解决了IntelliJ中的问题,方法是将两个缺失的依赖项转换为Repository,然后在maven中搜索这些依赖项,如下步骤所示:
发布于 2018-09-12 07:25:29
您使用的是HermiT 1.4.1.513。这与owlapi 5兼容,而不是4(补丁号与owlapi版本相匹配)。使用HermiT 1.3.8.413。
https://stackoverflow.com/questions/52273755
复制相似问题