Trong cấu hình xml tôi có thể làm như sau:
<context:property-placeholder
location="file:${user.home}/.config}/api.properties"
ignore-resource-not-found="true"
system-properties-mode="OVERRIDE"/>
Trong cấu hình java tôi sẽ làm như sau:
/**
* @return a {@link org.springframework.context.support.PropertySourcesPlaceholderConfigurer} so that placeholders are correctly populated
* @throws Exception exception if the file is not found or cannot be opened or read
*/
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() throws Exception {
PropertySourcesPlaceholderConfigurer propConfig = new PropertySourcesPlaceholderConfigurer();
Resource[] resources = new UrlResource[]
{new UrlResource("file:${user.home}/.config/api.properties")};
propConfig.setLocations(resources);
propConfig.setIgnoreResourceNotFound(true);
propConfig.setIgnoreUnresolvablePlaceholders(true);
return propConfig;
}
Tuy nhiên này doesn' t hiểu $ {user.home}
Ai đó đã bỏ phiếu hôm nay vì vậy tôi không thấy thực tế là vấn đề trùng lặp, rõ ràng điều này hiện có câu trả lời đúng để giải quyết vấn đề. Ngoài ra tôi không thể tìm thấy bản sao, người kiểm duyệt có thể cung cấp liên kết không? – shmish111
Đây KHÔNG phải là bản sao của "Thay đổi thuộc tính hệ thống của người dùng.home", như đã đề cập ở trên! Nó có liên quan, nhưng không giống nhau! Vui lòng xóa biểu ngữ trùng lặp hoặc cung cấp liên kết thích hợp cho một câu hỏi tương tự. – deluan
Đây không phải là bản sao, nó đặc biệt đề cập đến việc sử dụng Thuộc tính trong Mùa xuân có thuộc tính cú pháp và cấu hình riêng của nó xem http://www.baeldung.com/2012/02/06/properties-with-spring/ –