Art*_*hur 4 java spring annotations properties filenotfoundexception
配置
@Configuration
@PropertySources({
@PropertySource("classpath*:properties/test-database.properties")
})
public class DataSourceConfiguration {//...
}
Run Code Online (Sandbox Code Playgroud)
道具位置
D:\Projects\opti\dao\src\main\resources\properties\test-database.properties
Run Code Online (Sandbox Code Playgroud)
D:\Projects\opti\dao\src\main\resources 标记为资源文件夹。
小智 5
为了避免此类问题,问题是在VM 参数中设置 jboss.server.config.dir,如下所示:
-Djboss.server.config.dir="[jboss_repository]/server/[default-all-standard-standalone]/conf" \xe2\x80\x93server\nRun Code Online (Sandbox Code Playgroud)\n\n你像这样设置 PropertySource :
\n\n@Configuration\n@PropertySource("file:${jboss.server.config.dir}/file.properties")\nRun Code Online (Sandbox Code Playgroud)\n\n或者你这样设置你的属性
@PropertySource(value = "classpath:application.properties")\nRun Code Online (Sandbox Code Playgroud)\n\n执行时,将从位于类路径根目录中的application.properties文件导入属性。
| 归档时间: |
|
| 查看次数: |
7567 次 |
| 最近记录: |