我正在尝试使用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>代码在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文件中有没有什么重要的东西需要包含在内?
发布于 2018-05-31 09:02:18
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)
https://stackoverflow.com/questions/50610406
复制相似问题