未知的配置格式:hocon(支持的格式为:[json,raw,properties] [英] unknown configuration format: hocon (supported formats are: [json, raw, properties]

查看:321
本文介绍了未知的配置格式:hocon(支持的格式为:[json,raw,properties]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Hocon格式在Vertx中进行配置.我还为它添加了Maven依赖项.

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

<dependency>
            <groupId>com.typesafe</groupId>
            <artifactId>config</artifactId>
            <version>1.3.3</version>
        </dependency>

        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-config-hocon</artifactId>
            <version>3.5.1</version>
        </dependency>

代码在eclipse中可以正常编译.

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));

但是,当我运行二进制文件并将hocon配置文件作为命令行参数传递时,我收到以下未知的配置异常:

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]

我还检查了jar文件中的io.vertx.config.spi.ConfigProcessor.而且我找不到预期的io.vertx.config.hocon.HoconProcessor.

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.

我在POM文件中缺少一些构建配置吗?为了解决此问题,POM文件中是否包含任何重要的内容.

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.

推荐答案

使用SPI文件(META-INF/services/io.vertx.config.spi.ConfigProcessor文件)配置vertx-config格式.您可以在最终的jar中检查此文件的内容吗?要工作,它必须包含io.vertx.config.hocon.HoconProcessor行.由于您还依赖于vertx-config(也包含此文件),因此需要配置Maven Shader插件以将不同的文件组合为一个文件.检查 https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#ServicesResourceTransformer 以获得详细信息. Vert.x Maven插件会自动执行此操作( https://github.com/reactiverse/vertx- maven-plugin )

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)

这篇关于未知的配置格式:hocon(支持的格式为:[json,raw,properties]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆