You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Quarkus Native+Gradle环境下Blaze Persistence使用异常排查

Quarkus Native模式下Blaze Persistence实体视图报错的解决方法

问题场景

在Quarkus项目中使用Blaze Persistence实体视图时,JVM模式运行正常,但切换到GraalVM Native模式后,调用evm.applySetting方法时触发异常,核心提示实体视图类未被找到,即使给视图接口添加了@RegisterForReflection注解也无法解决。

报错代码片段

public List<CountryView> getCountries2(){
  CriteriaBuilder<Country> cb = cbf.create(em, Country.class);
  // 该行触发报错
  return evm.applySetting(EntityViewSetting.create(CountryView.class), cb).getResultList();
}

核心报错堆栈

Caused by: javassist.NotFoundException: io.airlinesuite.scheduling.api.rest.dto.CountryView
    at javassist.ClassPool.get(ClassPool.java:430)
    at com.blazebit.persistence.view.impl.proxy.ProxyFactory.createProxyClass(ProxyFactory.java:391)
    ... 45 more

实体视图定义

@EntityView(Country.class)
@RegisterForReflection
public interface CountryView {
    @IdMapping
    UUID getId();
    String getCountryName();
    String getCountryCode();
}

原Gradle依赖配置

dependencies {
    implementation 'io.quarkus:quarkus-arc'
    implementation 'io.quarkus:quarkus-resteasy'
    implementation 'io.quarkus:quarkus-resteasy-jackson'
    implementation 'io.quarkus:quarkus-resteasy-multipart'
    implementation 'io.quarkus:quarkus-hibernate-orm'
    implementation 'io.quarkus:quarkus-hibernate-validator'
    implementation 'io.quarkus:quarkus-jdbc-postgresql'
    implementation 'io.quarkus:quarkus-flyway'
    implementation 'org.mapstruct:mapstruct:1.5.3.Final'
    annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.3.Final'
    implementation 'io.quarkus:quarkus-smallrye-jwt'
    implementation 'io.quarkus:quarkus-smallrye-jwt-build'

    implementation enforcedPlatform("${quarkusPlatformGroupId}:quarkus-blaze-persistence-bom:${quarkusPlatformVersion}")
    implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
    implementation 'com.blazebit:blaze-persistence-integration-quarkus-3'
    runtimeOnly("com.blazebit:blaze-persistence-integration-hibernate-6.2")

    testImplementation 'io.quarkus:quarkus-junit5'
    testImplementation 'io.rest-assured:rest-assured'
}

解决方法

在Gradle的dependencies配置中添加Blaze Persistence实体视图注解处理器依赖:

annotationProcessor 'com.blazebit:blaze-persistence-entity-view-processor:1.6.9'

添加完成后重新构建Native镜像,即可解决该问题。

内容的提问来源于stack exchange,提问作者BigONotation

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 11:48:37