java.lang.NoClassDefFoundError: dk/brics/automaton/BasicAutomata Execption

java.lang.NoClassDefFoundError: dk/brics/automaton/BasicAutomata Execption

我正在使用 owlapi return 给定 class 的个体。在使用 pizza ontology 测试代码时它工作得很好但是当我在我的 ontology 上测试它时出现以下异常:

Exception in thread "main" java.lang.NoClassDefFoundError: dk/brics/automaton/BasicAutomata
    at org.semanticweb.HermiT.datatypes.rdfplainliteral.RDFPlainLiteralPatternValueSpaceSubset.<clinit>(RDFPlainLiteralPatternValueSpaceSubset.java:49)
    at org.semanticweb.HermiT.datatypes.rdfplainliteral.RDFPlainLiteralDatatypeHandler.registerPatternDatatype(RDFPlainLiteralDatatypeHandler.java:53)
    at org.semanticweb.HermiT.datatypes.rdfplainliteral.RDFPlainLiteralDatatypeHandler.<clinit>(RDFPlainLiteralDatatypeHandler.java:45)
    at org.semanticweb.HermiT.datatypes.DatatypeRegistry.<clinit>(DatatypeRegistry.java:44)
    at org.semanticweb.HermiT.structural.OWLClausification$DataRangeConverter.visit(OWLClausification.java:744)
    at org.semanticweb.owlapi.model.OWLDatatype.accept(OWLDatatype.java:141)
    at org.semanticweb.HermiT.structural.OWLClausification$DataRangeConverter.convertDataRange(OWLClausification.java:730)
    at org.semanticweb.HermiT.structural.OWLClausification$NormalizedAxiomClausifier.visit(OWLClausification.java:574)
    at org.semanticweb.owlapi.model.OWLDataAllValuesFrom.accept(OWLDataAllValuesFrom.java:52)
    at org.semanticweb.HermiT.structural.OWLClausification.clausify(OWLClausification.java:162)
    at org.semanticweb.HermiT.structural.OWLClausification.preprocessAndClausify(OWLClausification.java:92)
    at org.semanticweb.HermiT.Reasoner.loadOntology(Reasoner.java:210)
    at org.semanticweb.HermiT.Reasoner.<init>(Reasoner.java:201)
    at org.semanticweb.HermiT.Reasoner.<init>(Reasoner.java:175)
    at org.semanticweb.HermiT.ReasonerFactory.createHermiTOWLReasoner(ReasonerFactory.java:51)
    at org.semanticweb.HermiT.ReasonerFactory.createReasoner(ReasonerFactory.java:19)
    at org.semanticweb.HermiT.ReasonerFactory.createReasoner(ReasonerFactory.java:15)
    at Main.main(Main.java:40)
Caused by: java.lang.ClassNotFoundException: dk.brics.automaton.BasicAutomata
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 18 more

我注意到问题是由于我在 ontology 中使用的数据属性引起的。 (当我删除所有它工作的数据属性但是当我添加它们时错误再次出现)

您应该在您的项目中添加 pom.xml 中的依赖项:

第一个:

将以下依赖项添加到项目的 pom.xml 中。

<dependency>
    <groupId>dk.brics.automaton</groupId>
    <artifactId>automaton</artifactId>
    <version>1.11-8</version>
</dependency>

第二个:

在项目的根目录中执行 mvn package