com.typesafe.config.ConfigException $ Missing:找不到密钥的配置设置 [英] com.typesafe.config.ConfigException$Missing: No configuration setting found for key
问题描述
我正在使用typeSafe config将src/main/resources下存在的application.properties的属性加载到Scala代码中.从eclipse运行代码时,将加载属性.但是当以jar文件运行时,它抛出了一个错误.
I am using typeSafe config to load the properties from application.properties present under src/main/resources into Scala code. While running the code from eclipse, the properties are getting loaded. But while running as a jar file,its throwing me an error.
com.typesafe.config.ConfigException$Missing: No configuration setting found for key
推荐答案
感谢Wang给我一个线索.是的,jar文件包含属性文件.但是它无法找到该文件,因为该资源文件存在于resouces文件夹中.我知道何时解压缩jar文件.在代码中提供了以下内容.
Thanks Wang for giving me a clue. Yes, the jar file contains the property file. But it was not able to find the file, as the property file was present in resouces folder. I got to know when I unzip the jar file. In code had provided the below.
val config=ConfigFactory.load("application.properties")
当我将其更改为-
val config=ConfigFactory.load("resources/application.properties")
我正在获取属性.谢谢.
i am getting the properties. THANKS ALL.
这篇关于com.typesafe.config.ConfigException $ Missing:找不到密钥的配置设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!