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

如何在Helidon MP中正确配置Jersey的自定义配置属性

Helidon MP 配置 Jersey 自定义属性的正确方案

你可以选择以下任意一种方式完成配置,均可正常生效:

方式一:代码方式配置(优先级最高,最稳妥)

自定义 JAX-RS 应用类继承 ResourceConfig,直接在构造方法中设置属性:

import jakarta.ws.rs.ApplicationPath;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.ServerProperties;

@ApplicationPath("/")
public class CustomJaxRsApplication extends ResourceConfig {
    public CustomJaxRsApplication() {
        // 替换为你自己的资源类所在包路径
        packages("com.your.business.resources");
        // 直接设置 Jersey 官方属性
        property(ServerProperties.UNWRAP_COMPLETION_STAGE_IN_WRITER_ENABLE, true);
    }
}

方式二:配置文件方式(适合多环境动态调整)

Helidon MP 要求所有 Jersey 配置项需要添加 mp.jersey 前缀才能被识别,你之前的配置缺少前缀导致不生效,正确的 microprofile-config.properties 配置如下:

mp.jersey.config.server.unwrap.completion.stage.writer.enable=true

注意:如果两种配置同时存在,代码配置的值会覆盖配置文件中的值。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.27 17:15:08