1
我試圖做的正是@Laplie安德森這裏建議Spring Environment backed by Typesafe Config但在彈簧加載啓動的應用程序支持的彈簧引導環境。通過類型安全配置
我想加載不同的配置文件不同的彈簧作用輪廓。這是一個例子。
@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 {}
,但這會導致應用程序啓動時出現以下錯誤..
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]
...
我缺少什麼?
有沒有更好的方式來做到這一點?
以下版本在作怪這裏..
春季啓動:1.5.6.RELEASE
類型安全配置:1.3.1
我也有同樣的問題,面對,你有沒有發現無論如何使用HOCON配置以及啓動 – Ysak
我用.yml文件,而不是HOCON在其他評論中提及。 – Gagan