私はWEB-INF
フォルダにあるSpringを使ってプロパティファイルをロードしようとしています。なぜSpringのPropertySourceはFileNotFoundExceptionをスローしますか?
私は、次のエラーが発生します:ここで
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.elastictest.config.ProdConfig]; nested exception is java.io.FileNotFoundException: \WEB-INF\config\prod.properties (The system cannot find the path specified)
は私のプロダクション設定ファイルである:ここで
@Configuration
@Profile("prod")
@PropertySource("file:${prodPropertiesFile}")
public class ProdConfig {
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
は私のweb.xmlの宣言です:
<context-param>
<param-name>prodPropertiesFile</param-name>
<param-value>/WEB-INF/config/prod.properties</param-value>
</context-param>
私が開いています戦争を確認し、プロパティファイルがWEB-INF/configフォルダの下にあることを確認しました。何か案は?
コンテキストパラメータのwen.xml宣言を削除した場合、prodPropertiesFileは何を参照するのですか – user1154644
私のやり方を試しますか?春には必要ありません4.名前と値があります。名前はhttp://で確認できますdocs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/annotation/PropertySource.html –
はい、私は同じ結果を試しました。私は本当にこの1つに困っています – user1154644