如何获得HOCON配置文件格式以在以胖子形式部署的Vert.x中工作? [英] How can I get the HOCON configuration file format to work in Vert.x deployed as fat jar?
问题描述
我想使用 HOCON 格式在作为胖子部署的Vert.x应用程序中进行配置.我正面临中描述的相同问题问题.
I want to use the HOCON format for configuration in a Vert.x application deployed as a fat jar. I'm facing the same issue as described in this similar question.
但是我应用了gradle插件"io.vertx.vertx-plugin"(v1.0.1),并成功地将io.vertx.config.hocon.HoconProcessor
行插入了jar中的META-INF/services/io.vertx.config.spi.ConfigProcessor
中.
However I applied the gradle Plugin "io.vertx.vertx-plugin" (v1.0.1) and succeeded in getting the line io.vertx.config.hocon.HoconProcessor
into META-INF/services/io.vertx.config.spi.ConfigProcessor
in the jar.
我仍然得到例外.在jar中正确绑定HoconProcessor类还需要什么?
I still get the exception. What else could be required for the proper bundling of the HoconProcessor class in the jar?
推荐答案
我遇到了同样的问题,花了很长时间才弄清楚问题出在哪里.就我而言,我正在使用gradle shadowJar插件构建一个胖子罐.要启动该应用程序,我使用了vertx
命令,该命令导致了所描述的错误.使用java -jar my-fat-jar.jar
直接用java启动应用程序是没有问题的.
I had the same problem and it took quite a while to figure out what the problem was. In my case I was building a fat jar using the gradle shadowJar plugin. To start the application I used the vertx
command what resulted in the described error. Starting the application directly with java using java -jar my-fat-jar.jar
was no problem.
因此,我查看了vertx脚本,发现类路径的设置如下:CLASSPATH=${CLASSPATH}:${VERTX_HOME}/conf:${VERTX_HOME}/lib/*
因此,胖子实际上不在类路径中,并且找不到YAML的ConfigProcessor.使用CLASSPATH=my-fat-jar.jar vertx run my-fat-jar.jar
可以正常工作.
So I had a look into the vertx script and found out that the classpath is set like this: CLASSPATH=${CLASSPATH}:${VERTX_HOME}/conf:${VERTX_HOME}/lib/*
so the fat jar is actually not in the classpath and the ConfigProcessor for YAML can not be found. Using CLASSPATH=my-fat-jar.jar vertx run my-fat-jar.jar
works properly.
因此,您可以使用它,也可以如上所述使用Java直接启动应用程序.
So you can either use this or start you application directly using java as described above.
这篇关于如何获得HOCON配置文件格式以在以胖子形式部署的Vert.x中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!