網上的資料一般在使用@PropertySource的時候,都喜歡用@PropertySource("classpath:/document.properties")這種形式
現在我把資源文件的路徑放在application.properties里
config.path=/home/myservice/config.properties
然后在java源碼里:
@PropertySource(value = {"${config.path}"}, encoding="utf-8")
public class MyConfig {
@Value("${myconfig.index}")
private String index;
public String getIndex() {
return index;
}
}
但是出錯:
Caused by: java.io.FileNotFoundException: class path resource [home/myservice/config.properties] cannot be opened because it does not exist
添加回答
舉報
0/150
提交
取消