Maven 阴影 IllegalStateException - 缺少必需的 class 信息
Maven shade IllegalStateException - Required class information is missing
我刚刚使用 JavaFX 和 Hibernate 构建了一个应用程序,它在 IntelliJ 上构建并 运行 完美,所以我选择使用 maven shade 插件生成一个“fat-jar”,因为我使用了一些具有自动模块名称的库,所以我不能使用 jlink。
Jar 创建良好,它可以正确加载初始屏幕,但是当它尝试连接到我的数据库时,特别是这一行有问题 (JPAUtil.java:19);
factory = Persistence.createEntityManagerFactory(persistenceUnit, properties);
我得到以下异常;
java.lang.IllegalStateException: Required class information is missing
at org.jboss.jandex.Indexer.rebuildNestedType(Indexer.java:926)
at org.jboss.jandex.Indexer.resolveTypePath(Indexer.java:786)
at org.jboss.jandex.Indexer.resolveTypeAnnotation(Indexer.java:705)
at org.jboss.jandex.Indexer.resolveTypeAnnotations(Indexer.java:613)
at org.jboss.jandex.Indexer.index(Indexer.java:1602)
at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.toClassDescriptor(ClassFileArchiveEntryHandler.java:64)
at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.handleEntry(ClassFileArchiveEntryHandler.java:52)
at org.hibernate.boot.archive.internal.JarFileBasedArchiveDescriptor.visitArchive(JarFileBasedArchiveDescriptor.java:147)
at org.hibernate.boot.archive.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:48)
at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:76)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:98)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:254)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:175)
at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:76)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:171)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:119)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:61)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:50)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at com.it.util.JPAUtil.getEntityManagerFactory(JPAUtil.java:19)
at com.it.controller.HomeController.initializeSettings(HomeController.java:1571)
at com.it.controller.HomeController.initialize(HomeController.java:1407)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2573)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2466)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3237)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3113)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3106)
at com.it.Home.start(Home.java:23)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1(LauncherImpl.java:846)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait(PlatformImpl.java:455)
at com.sun.javafx.application.PlatformImpl.lambda$runLater(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater(PlatformImpl.java:427)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
我知道语法是正确的,正如我之前提到的 运行 在 IDE 上是正确的,所以我怀疑它在 shade 生成的 jar 文件中丢失了一些东西,但是我已经花了已经将近 3 天了,我根本找不到原因。堆栈跟踪中显示的信息没有多大帮助,至少我什么也没看到——我什至查看了堆栈跟踪中提到的所有 类,它们似乎都在生成的 Jar 中。
希望这里的任何人在 maven 阴影过程中都有类似的东西,或者可能比我更熟悉。任何帮助或要点将不胜感激。
有助于确定问题的其他文件如下;
persistence.xml - 其他属性从代码上的 XML 文件加载。
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="Project-Postgre">
<description>Hibernate JPA Configuration</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value = "false" />
</properties>
</persistence-unit>
</persistence>
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.it</groupId>
<artifactId>Project</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<javafx.version>14</javafx.version>
</properties>
<name>Project</name>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/de.jensd/fontawesomefx -->
<dependency>
<groupId>de.jensd</groupId>
<artifactId>fontawesomefx</artifactId>
<version>8.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.20.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.15</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc10 -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc10</artifactId>
<version>19.7.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${maven.compiler.release}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>com.it.HomeFX</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>project-classifier</shadedClassifierName>
<outputFile>target\shade${project.artifactId}.jar</outputFile>
<transformers>
<transformer implementation=
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.it.HomeFX</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
JPAUtil
public static EntityManagerFactory getEntityManagerFactory(String persistenceUnit, String connectionURL, String user, String password) {
if (factory == null) {
Map<String, String> properties = new HashMap<>();
properties.put("javax.persistence.jdbc.url", connectionURL);
properties.put("javax.persistence.jdbc.user", user);
properties.put("javax.persistence.jdbc.password", password);
factory = Persistence.createEntityManagerFactory(persistenceUnit, properties);
}
return factory;
}
我已经通过从 Hibernate 切换到 OpenJPA 来解决这个问题。
Hibernate 没有提供足够的信息来调试问题,当切换到 OpenJPA 时,我只需要将它添加到我的 pom.xml;
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-all</artifactId>
<version>3.1.2</version>
</dependency>
Shade 创建了包含所有必需库的 JAR 并成功连接到数据库。
我遇到了同样的问题。我试图将 PostgreSQL JDBC 驱动程序版本降级到 42.0.0。异常消失,一切正常。
我在使用时遇到了同样的错误:
spring.version:5.2.7.RELEASE
spring.boot.version:2.3.1.RELEASE
postgresql-version:42.2.16
从 42.2.15 开始的所有 postgres 版本都会发生这种情况。版本 42.2.14(或更早版本)适合我。
此问题是由 javac
1.8 生成的无效字节码引起的(例如,已知 AdoptOpenJDK 1.8u222 会受到影响)。
这是问题(与复制器):https://github.com/wildfly/jandex/issues/92
修复是更新到 org.jboss:jandex:2.2.3.Final
,其中包括解决方法(以及一些其他类型注释修复),或使用 Java 11 编译器(== javac
11 ).
为了以防万一,org.postgresql:postgresql:42.2.15
触发了问题,因为它使用了 the Checker Framework for nullness verification,并且它包含多个 @Nullable
和 @NonNull
注释以使验证通过。
即将推出的 org.postgresql:42.2.18
和 org.postgresql:42.3.0
将有 the relevant workarounds,因此它也适用于旧的 jandex
版本。
如果您正在阅读这里,我建议将 forbidden-apis and jandex 字节码解析器(例如 de.thetaphi.forbiddenapis
和 com.github.vlsi.jandex
Gradle 插件)添加到您的构建管道中以捕获无效的字节码早期(否则可能会被忽视),特别是如果你仍然使用 javac
1.8.
最终,已在 PostgreSQL JDBC 驱动程序版本 42.2.19 中修复,请参阅 https://jdbc.postgresql.org/documentation/changelog.html#version_42.2.19。
将您的版本更新到 42.2.19 应该可以解决问题。
我刚刚使用 JavaFX 和 Hibernate 构建了一个应用程序,它在 IntelliJ 上构建并 运行 完美,所以我选择使用 maven shade 插件生成一个“fat-jar”,因为我使用了一些具有自动模块名称的库,所以我不能使用 jlink。
Jar 创建良好,它可以正确加载初始屏幕,但是当它尝试连接到我的数据库时,特别是这一行有问题 (JPAUtil.java:19);
factory = Persistence.createEntityManagerFactory(persistenceUnit, properties);
我得到以下异常;
java.lang.IllegalStateException: Required class information is missing
at org.jboss.jandex.Indexer.rebuildNestedType(Indexer.java:926)
at org.jboss.jandex.Indexer.resolveTypePath(Indexer.java:786)
at org.jboss.jandex.Indexer.resolveTypeAnnotation(Indexer.java:705)
at org.jboss.jandex.Indexer.resolveTypeAnnotations(Indexer.java:613)
at org.jboss.jandex.Indexer.index(Indexer.java:1602)
at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.toClassDescriptor(ClassFileArchiveEntryHandler.java:64)
at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.handleEntry(ClassFileArchiveEntryHandler.java:52)
at org.hibernate.boot.archive.internal.JarFileBasedArchiveDescriptor.visitArchive(JarFileBasedArchiveDescriptor.java:147)
at org.hibernate.boot.archive.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:48)
at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:76)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:98)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:254)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:175)
at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:76)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:171)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:119)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:61)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:50)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at com.it.util.JPAUtil.getEntityManagerFactory(JPAUtil.java:19)
at com.it.controller.HomeController.initializeSettings(HomeController.java:1571)
at com.it.controller.HomeController.initialize(HomeController.java:1407)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2573)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2466)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3237)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3113)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3106)
at com.it.Home.start(Home.java:23)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1(LauncherImpl.java:846)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait(PlatformImpl.java:455)
at com.sun.javafx.application.PlatformImpl.lambda$runLater(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater(PlatformImpl.java:427)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
我知道语法是正确的,正如我之前提到的 运行 在 IDE 上是正确的,所以我怀疑它在 shade 生成的 jar 文件中丢失了一些东西,但是我已经花了已经将近 3 天了,我根本找不到原因。堆栈跟踪中显示的信息没有多大帮助,至少我什么也没看到——我什至查看了堆栈跟踪中提到的所有 类,它们似乎都在生成的 Jar 中。 希望这里的任何人在 maven 阴影过程中都有类似的东西,或者可能比我更熟悉。任何帮助或要点将不胜感激。
有助于确定问题的其他文件如下;
persistence.xml - 其他属性从代码上的 XML 文件加载。
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="Project-Postgre">
<description>Hibernate JPA Configuration</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value = "false" />
</properties>
</persistence-unit>
</persistence>
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.it</groupId>
<artifactId>Project</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<javafx.version>14</javafx.version>
</properties>
<name>Project</name>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/de.jensd/fontawesomefx -->
<dependency>
<groupId>de.jensd</groupId>
<artifactId>fontawesomefx</artifactId>
<version>8.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.20.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.15</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc10 -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc10</artifactId>
<version>19.7.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${maven.compiler.release}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>com.it.HomeFX</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>project-classifier</shadedClassifierName>
<outputFile>target\shade${project.artifactId}.jar</outputFile>
<transformers>
<transformer implementation=
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.it.HomeFX</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
JPAUtil
public static EntityManagerFactory getEntityManagerFactory(String persistenceUnit, String connectionURL, String user, String password) {
if (factory == null) {
Map<String, String> properties = new HashMap<>();
properties.put("javax.persistence.jdbc.url", connectionURL);
properties.put("javax.persistence.jdbc.user", user);
properties.put("javax.persistence.jdbc.password", password);
factory = Persistence.createEntityManagerFactory(persistenceUnit, properties);
}
return factory;
}
我已经通过从 Hibernate 切换到 OpenJPA 来解决这个问题。 Hibernate 没有提供足够的信息来调试问题,当切换到 OpenJPA 时,我只需要将它添加到我的 pom.xml;
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-all</artifactId>
<version>3.1.2</version>
</dependency>
Shade 创建了包含所有必需库的 JAR 并成功连接到数据库。
我遇到了同样的问题。我试图将 PostgreSQL JDBC 驱动程序版本降级到 42.0.0。异常消失,一切正常。
我在使用时遇到了同样的错误: spring.version:5.2.7.RELEASE spring.boot.version:2.3.1.RELEASE postgresql-version:42.2.16
从 42.2.15 开始的所有 postgres 版本都会发生这种情况。版本 42.2.14(或更早版本)适合我。
此问题是由 javac
1.8 生成的无效字节码引起的(例如,已知 AdoptOpenJDK 1.8u222 会受到影响)。
这是问题(与复制器):https://github.com/wildfly/jandex/issues/92
修复是更新到 org.jboss:jandex:2.2.3.Final
,其中包括解决方法(以及一些其他类型注释修复),或使用 Java 11 编译器(== javac
11 ).
为了以防万一,org.postgresql:postgresql:42.2.15
触发了问题,因为它使用了 the Checker Framework for nullness verification,并且它包含多个 @Nullable
和 @NonNull
注释以使验证通过。
即将推出的 org.postgresql:42.2.18
和 org.postgresql:42.3.0
将有 the relevant workarounds,因此它也适用于旧的 jandex
版本。
如果您正在阅读这里,我建议将 forbidden-apis and jandex 字节码解析器(例如 de.thetaphi.forbiddenapis
和 com.github.vlsi.jandex
Gradle 插件)添加到您的构建管道中以捕获无效的字节码早期(否则可能会被忽视),特别是如果你仍然使用 javac
1.8.
最终,已在 PostgreSQL JDBC 驱动程序版本 42.2.19 中修复,请参阅 https://jdbc.postgresql.org/documentation/changelog.html#version_42.2.19。
将您的版本更新到 42.2.19 应该可以解决问题。