未知配置格式:HOCON(支持的格式为:[JSON、原始、属性]



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

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

代码在日食中编译良好。

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 配置文件作为命令行参数传递时,我收到以下未知配置异常:

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

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

我是否在 POM 文件中缺少一些构建配置?POM文件中是否有任何重要的东西可以解决此问题。

顶点配置格式是使用 SPI 文件(META-INF/services/io.vertx.config.spi.ConfigProcessor文件(配置的。你能在最终的 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(

最新更新