如何使用Maven在MacOS 12(默认运行Java 19)上编译和运行owlapi项目?



自从升级到MacOS 12,当我运行依赖于owlapi的项目,这些项目是用Maven编译的,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>

从5。几年前在欧拉皮的X分部。尝试将owlapi更新到5.1.20,并删除pom中的显式向导依赖。这应该排除所有指南引用。如果有必要,也将其从jfact依赖中排除(我没有尝试过jfact与任何java版本超过8,但我希望它能工作,它没有任何已知与新jdk不兼容的功能。

最新更新