如何使用Maven在MacOS12(默认情况下运行Java19)上编译和运行owlapi项目?

6ss1mwsb  于 2022-12-11  发布在  Maven
关注(0)|答案(1)|浏览(121)

自从升级到MacOS 12后,当我运行用Maven编译的依赖于owlapi的项目时,owlapi依赖的Guice库在启动时抛出了几种不同类型的异常。我该怎么做才能解决这个问题?
例如:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.inject.internal.BytecodeGen.getClassLoader(Ljava/lang/Class;)Ljava/lang/ClassLoader;

com.google.inject.internal.MessageProcessor visit
INFO: An exception was caught and reported. Message: java.lang.NoSuchMethodException: uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.<init>()

com.google.inject.CreationException: Unable to create injector, see the following errors:

1) An exception was caught and reported. Message: Injection failed for interface OWLOntologyFactory
  at [unknown source]

1 error

======================
Full classname legend:
======================
OWLOntologyFactory: "org.semanticweb.owlapi.model.OWLOntologyFactory"
========================
End of classname legend:
========================

    at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:576)
    at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:163)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
    at com.google.inject.Guice.createInjector(Guice.java:87)
    at com.google.inject.Guice.createInjector(Guice.java:69)
    at com.google.inject.Guice.createInjector(Guice.java:59)
    at org.semanticweb.owlapi.apibinding.OWLManager.<clinit>(OWLManager.java:42)
    ... 2 more

下面是我正在使用的pom文件中的依赖项:

<dependencies>
        <dependency>
            <groupId>net.sourceforge.owlapi</groupId>
            <artifactId>jfact</artifactId>
            <version>5.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.7</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.6.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.owlapi</groupId>
            <artifactId>owlapi-rio</artifactId>
            <version>5.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>5.1.0</version>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.owlapi</groupId>
            <artifactId>owlapi-distribution</artifactId>
            <version>5.1.0</version>
        </dependency>
        <dependency>
            <groupId>ch.securityvision</groupId>
            <artifactId>xattrj</artifactId>
            <version>1.3</version>
        </dependency>
    </dependencies>
mqxuamgl

mqxuamgl1#

guice依赖几年前就从owlapi的5.x分支中删除了。尝试将owlapi更新到5.1.20并删除pom中显式的guice依赖。这应该会排除所有guice引用。如果必要的话,也将其从jfact依赖中排除(我没有在任何超过8的java版本中尝试过jfact,但我希望它能工作,它没有任何已知的与较新的jdk不兼容的特性。

相关问题