Reputation: 2081
I try to get a list from a config according to this example: How to get a list with the Typesafe config library
However, I get following exception:
Exception in thread "main" com.typesafe.config.ConfigException$WrongType: application.properties @ file:/xxx/application.properties: configYYY has type STRING rather than LIST
at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:159)
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:170)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:184)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189)
at com.typesafe.config.impl.SimpleConfig.getList(SimpleConfig.java:252)
at com.typesafe.config.impl.SimpleConfig.getHomogeneousUnwrappedList(SimpleConfig.java:323)
at com.typesafe.config.impl.SimpleConfig.getStringList(SimpleConfig.java:381)
How can I get a list from typesafe? Below are my test code:
class Test extends FlatSpec {
"Test" should "be about to get list" in {
val configFactory = ConfigFactory.load();
var disabledExtension = configFactory.getStringList("disabledExtension");
assert(2==disabledExtension.size());
assert(disabledExtension.get(0).equals("SH"));
assert(disabledExtension.get(1).equals("ST"));
}
}
And below my application.properties:
disabledExtension = ["SH", "ST"]
Upvotes: 2
Views: 3621
Reputation: 107
application.properties has to be application.conf
Any property in "*.properties" file would be read as a string.
Upvotes: 1