代码之家  ›  专栏  ›  技术社区  ›  Bruno Pessanha

使用SWRL API使用Gradle创建SWRL规则时出现依赖性问题

  •  3
  • Bruno Pessanha  · 技术社区  · 6 年前

    我正在尝试使用swrlapi和owlapi将swrl规则添加到我的本体中。我正在尝试使用与swrlapi兼容的owlapi版本。但是,创建规则时仍然会出错。这似乎是依赖关系管理的问题。我使用Gradle作为依赖关系管理器,因此这应该解决了这个问题。

    例外情况是:

    创建规则引擎下垂时出错。异常:java.lang.NoClassedeffoundError。消息: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'
    }
    

    执行时发生异常 创建规则引擎 方法:

    public void addNewSWRLRule(SWRLRuleModel rule) throws SWRLBuiltInException, SWRLParseException {    
        SWRLRuleEngine swrlRuleEngine = SWRLAPIFactory.createSWRLRuleEngine(ontology);
        swrlRuleEngine.infer();
        swrlRuleEngine.createSWRLRule(rule.getName(), rule.getRule(), rule.getComment(), true);
    }
    

    是否存在必须手动添加才能解决此问题的依赖项?

    2 回复  |  直到 6 年前
        1
  •  0
  •   Ignazio    6 年前

    你在使用隐士1.4.1.513。这与owlapi 5兼容,而不是4(补丁号与owlapi版本匹配)。使用Hermit 1.3.8.413。

        2
  •  0
  •   Bruno Pessanha    6 年前

    问题是,Gradle没有解决Drools引擎(edu.stanford.swrl:swrlapi Drools引擎:2.0.5)的2个Maven依赖项。

    缺少的依赖项为:

    • 组织进度:知识API:6.5.0.最终
    • 组织速降:速降OSGi集成:6.5.0.最终

    我不确定是什么导致这些问题不能由Gradle解决,但我设法通过将缺少的两个依赖项转换为存储库库并在Maven中按以下步骤搜索来解决Intellij中的问题:

    1. 文件>项目结构>库
    2. 右键单击丢失的库
    3. 转换为存储库库
    4. 在Maven存储库中键入依赖项名称和搜索
    5. 替换