2017-08-04 7 views
1

@Laplie Andersonがここで提案したのはSpring Environment backed by Typesafe Configであるが、スプリングブートアプリケーションでは何をしようとしている。spring-bootタイプセーフな設定に裏打ちされた環境

私は、さまざまなスプリングアクティブプロファイルに異なる設定ファイルをロードしたいと思います。ここに例があります。

@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

+0

私も同じ問題に直面していますが、起動時にHOCON設定を使用することができましたか? – Ysak

+0

他のコメントで述べたようにHOCONの代わりに.ymlファイルを使用しました。 – Gagan

答えて

0

はちょうど春ブートが.ymlをサポートしていることに気づきました私が必要とするほとんどすべての機能を持つファイル、特に「プロパティのプレースホルダ」。代わりにこれを使用しようとしています - https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-yaml

私はまだ元の質問に対する答えを知りたいと思います。それは単に ':'がtypesafe-config値で受け入れられないからですか?回避策はありませんか?

関連する問題