无法启动 quarkus:java.lang.ArrayIndexOutOfBoundsException:1

Failed to start quarkus: java.lang.ArrayIndexOutOfBoundsException: 1

从 QuarkEE 工件创建的 Quarkus 应用程序 (0.19.1) 无法启动:

[io.qua.dev.DevModeMain] Failed to start quarkus: java.lang.ExceptionInInitializerError ..
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at io.quarkus.hibernate.validator.runtime.HibernateValidatorRecorder

编辑 我已经为它开了一张票: https://github.com/quarkusio/quarkus/issues/3284

根本原因 是枚举 class 的静态工厂方法上的 bean 验证约束 javax.validation.constraints.NotNull。简化示例:

public enum Gender {
    MALE,
    FEMALE;

    public static Gender fromCode(@NotNull String code) {
        return Gender.valueOf(code);
    }
}

并且在你的 pom 中有这个依赖:

    <dependency>
       <groupId>io.quarkus</groupId>
       <artifactId>quarkus-hibernate-validator</artifactId>
    </dependency>

令人困惑的是简单 POJO class 上的静态工厂方法有效。

备注 我知道 Bean 验证规范不支持静态方法的验证。这只是 IDE.

的提示

Java EE 8 Validating Constructors and Methods: Bean Validation constraints may be placed on the parameters of nonstatic methods and constructors and on the return values of nonstatic methods. Static methods and constructors will not be validated.