I'm trying to do exactly what @Laplie Anderson suggested here Spring Environment backed by Typesafe Config but in a spring-boot application.
I want to load different config files for different spring active profiles. Here's an example.
@Configuration()
@Import(value = {CommonConfiguration.class})
@PropertySource(factory=TypesafePropertySourceFactory.class, value="config/dev/app.conf")
@Profile("dev")
public class DevConfig {}
@Configuration()
@Import(value = {CommonConfiguration.class})
@PropertySource(factory=TypesafePropertySourceFactory.class, value="config/prod/app.conf")
@Profile("prod")
public class ProdConfig {}
But this results in the following error on app startup..
java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration.buildProperties
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64) ~[spring-boot-autoconfigure-1.5.6.RELEASE.jar!/:1.5.6.RELEASE]
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102) ~[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE]
...
Caused by: com.typesafe.config.ConfigException$BadPath: path parameter: Invalid path 'spring.info.build.location:classpath:META-INF/build-info.properties': Token not allowed in path expression: ':' (you can double-quote this token if you really want it here)
at com.typesafe.config.impl.PathParser.parsePathExpression(PathParser.java:155) ~[config-1.3.1.jar!/:na]
at com.typesafe.config.impl.PathParser.parsePathExpression(PathParser.java:74) ~[config-1.3.1.jar!/:na]
...
What am I missing?
Is there a better way to accomplish this?
The following versions are at play here..
spring-boot: 1.5.6.RELEASE
typesafe config: 1.3.1