hocon配置文件,未知的配置格式:hocon(支持的格式为:[json,原始,属性]

I am trying to use the Hocon format for configuration in Vertx. I have also added the maven dependency for it.

com.typesafe

config

1.3.3

io.vertx

vertx-config-hocon

3.5.1

The code compiles fine in eclipse.

Vertx vertx = Vertx.vertx();

DeploymentOptions options = new DeploymentOptions();

ConfigStoreOptions store = new ConfigStoreOptions().setType("file").setFormat("hocon").setConfig(new JsonObject().put("path", System.getProperty("configPath")));

ConfigRetriever retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(store));

However, when I run the binary and passing a hocon configuration file as a command line argument, I am getting the following unknown configuration exception:

java.lang.IllegalArgumentException: unknown configuration format: hocon (supported formats are: [json, raw, properties]

I have also checked io.vertx.config.spi.ConfigProcessor in the jar file. And I don't find the expected io.vertx.config.hocon.HoconProcessor.

Am I missing some build configuration in POM file? Is there any important thing to be included in the POM file to resolve this issue.

解决方案

The vertx-config formats are configured using a SPI file (META-INF/services/io.vertx.config.spi.ConfigProcessor file). Can you check the content of this file in your final jar? To work, it must contain the io.vertx.config.hocon.HoconProcessor line. As you are also depending on vertx-config (also containing this file), you need to configure the Maven Shader plugin to combine the different files into one. Check https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#ServicesResourceTransformer for details. The Vert.x Maven Plugin does that automatically (https://github.com/reactiverse/vertx-maven-plugin)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值