簡體   English   中英

未知配置格式:hocon(支持的格式為:[json,raw,properties]

[英]unknown configuration format: hocon (supported formats are: [json, raw, properties]

我試圖在Vertx中使用Hocon格式進行配置。 我還為它添加了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>

代碼在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配置文件作為命令行參數傳遞時,我收到以下未知配置異常:

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文件中以解決此問題。

vertx-config格式使用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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM