我正在使用Spring Boot並試圖讓我的應用程序能夠在運行時獲取配置文件。下面是我在春天文件spring classpath在WEB-INF/classes下找不到配置文件
<context:property-placeholder location="classpath:config.properties" />
但是當我開始
Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [config.properties] cannot be opened because it does not exist
我試圖將其更改爲
<context:property-placeholder location="classpath*:config.properties" />
我得到了不同的服務,我得到這個錯誤錯誤
Could not resolve placeholder 'service.name' in string value "${service.name}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'service.name' in string value "${service.name}"
看起來像我牛逼能找到該文件,但無法找到字符串(這是內部config.properties)
我把我的config.properties路徑下的WEB-INF /班/,WAR文件裏
788 Mon Oct 19 09:54:28 PDT 2015 WEB-INF/classes/config.properties
任何人有任何想法出了什麼問題?
在此先感謝!
添加您的'config.properties'代碼到您的文章,我們會知道你是如何試圖加載config.properties,RU使用'PropertyPlaceholderConfigurer' – Uppicharla