@Value
という変数に値を注入しています。何らかの理由で、私はデフォルト値を持っているときにのみそれを使用します、それはプロパティファイルでそれを探しません。デフォルト値を使用していないときは、プロパティファイルから値を挿入します。その他の設定は変更されていません。Spring @Valueはデフォルト値のみを使用します
@Value("${migration.paths:#{'classpath:db/migration'}}")
private String dbMigrationPaths;
(それはスラッシュを持っているので、私は、デフォルト値でSPELを使用しています)
プロパティファイルの設定:
@Bean
public static PropertySourcesPlaceholderConfigurer configDataSourcesPropertyFile() {
PropertySourcesPlaceholderConfigurer bean = new PropertySourcesPlaceholderConfigurer();
bean.setLocations(new ClassPathResource[]{
new ClassPathResource("/file1"),
new ClassPathResource("/file2")
});
bean.setIgnoreUnresolvablePlaceholders(true);
bean.setIgnoreResourceNotFound(true);
return bean;
}
質問が常駐では両方とも、プロパティファイル、および財産ですfile1
ありませんfile2
[こちらの投稿](https://stackoverflow.com/questions/28369582/spring-boot-spring-always-assigns-default-value-to-property-despite-of-it-bein)をご覧ください)、同様の問題のようです。 – juanlumn