Configuring Helidon WebClient for JsonbSupport reader, writer and media support through properties

huangapple go评论99阅读模式
英文:

Configuring Helidon WebClient for JsonbSupport reader, writer and media support through properties

问题

I want to configure my helidon web-client just using config.
Something like below:
WebClient.builder()
.config(Config.create().get("web-client")).build();

and my config looks like below:

web-client:
uri:
media-support:
services: //What should i add here which will be equivalent to below in webclient builder

            .addReader(JsonbSupport.reader())
            .addWriter(JsonbSupport.writer())
            .addMediaSupport(JsonbSupport.create())

I tried following config:

web-client:
uri:
media-support:
discover-services: true

It worked but I guess due to default reader/writers. Still I do not understand what will discover-services exactly do and if Json support will be added automatically using above config.

英文:

I want to configure my helidon web-client just using config.
Something like below:
WebClient.builder()
.config(Config.create().get("web-client")).build();

and my config looks like below:

web-client:
  uri:<my-base-uri>
  media-support:
     services: //What should i add here which will be equivalent to below in webclient builder
                .addReader(JsonbSupport.reader())
                .addWriter(JsonbSupport.writer())
                .addMediaSupport(JsonbSupport.create())

I tried following config:

web-client:
  uri:<my-base-uri>
  media-support:
    discover-services: true

It worked but I guess due to default reader/writers. Still I do not understand what will discover-services exactly do and if Json support will be added automatically using above config.

答案1

得分: 0

"discover-services属性意味着,Helidon将使用服务加载器加载类路径上存在的所有MediaSupportProviders

如果你添加了这个依赖:

<dependency>
    <groupId>io.helidon.media</groupId>
    <artifactId>helidon-media-jsonb</artifactId>
</dependency>

并且启用了discover-servicesJsonb支持将被自动发现并注册。"

英文:

discover-services property means, that Helidon will use service loader to load all MediaSupportProviders present on the classpath.

If you had this dependency added:

<dependency>
    <groupId>io.helidon.media</groupId>
    <artifactId>helidon-media-jsonb</artifactId>
</dependency>

and discover-services enabled, complete Jsonb support was found and registered automatically for you.

huangapple
  • 本文由 发表于 2023年5月25日 23:14:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76333859.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定