[英]place holder property is not resolved
我正在使用@Configuration
並使用@Value
注釋設置屬性ehCacheConfig
:
@Configuration
public class CacheConfig {
@Value("${configPath}")
private Resource ehCacheConfig;
}
但是,在運行項目時,將發生以下錯誤。 由於錯誤表明占位符屬性configPath
不能被spring容器解析。 誰能告訴我為什么?
java.io.FileNotFoundException:無法打開ServletContext資源[/ $ {configPath}] org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141)org.springframework.cache.ehcache.EhCacheManagerUtils.parseConfiguration( EhCacheManagerUtils.java:107)
您需要定義一個PropertySource
從那里加載configPath
的值:
@Configuration
@PropertySource("classpath:/com/myco/app.properties")
public class CacheConfig {
@Value("${configPath}")
private Resource ehCacheConfig;
}
app.properties :
configPath: /home/[...]/myConfig.xml
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.