|
|
@@ -119,12 +119,19 @@ public class DynamicProperties {
|
|
|
try {
|
|
|
File propertyFile = new File(PROPERTY_FILE_NAME);
|
|
|
if (!propertyFile.exists()) {
|
|
|
- // 复制类路径下默认的配置文件
|
|
|
- File defaultPropertyFile = ResourceUtils.getFile(PROPERTY_FILE_NAME);
|
|
|
- if (defaultPropertyFile == null) {
|
|
|
- throw new FileNotFoundException("配置文件不存在:" + PROPERTY_FILE_NAME);
|
|
|
+ // 配置文件不存在时,加载旧的配置文件(以兼容旧的配置方式)
|
|
|
+ // TODO temporary codes
|
|
|
+ File oldPropertyFile = new File("application.properties");
|
|
|
+ if (oldPropertyFile.exists() && oldPropertyFile.isFile()) {
|
|
|
+ FileUtils.copy(oldPropertyFile, propertyFile);
|
|
|
+ } else {
|
|
|
+ // 复制类路径下默认的配置文件
|
|
|
+ File defaultPropertyFile = ResourceUtils.getFile(PROPERTY_FILE_NAME);
|
|
|
+ if (defaultPropertyFile == null) {
|
|
|
+ throw new FileNotFoundException("配置文件不存在:" + PROPERTY_FILE_NAME);
|
|
|
+ }
|
|
|
+ FileUtils.copy(defaultPropertyFile, propertyFile);
|
|
|
}
|
|
|
- FileUtils.copy(defaultPropertyFile, propertyFile);
|
|
|
}
|
|
|
long lastModified = propertyFile.lastModified();
|
|
|
// 如果配置文件有修改,就重新加载
|
|
|
@@ -137,6 +144,24 @@ public class DynamicProperties {
|
|
|
Properties properties = new Properties();
|
|
|
properties.load(new FileInputStream(propertyFile));
|
|
|
|
|
|
+ // TODO temporary codes
|
|
|
+ if(!properties.containsKey("max-record-size.pc")){
|
|
|
+ properties.put("max-record-size.pc", "100000");
|
|
|
+ properties.store(new FileOutputStream(propertyFile), "report properties updated on");
|
|
|
+ }
|
|
|
+ if(!properties.containsKey("max-record-size.phone")){
|
|
|
+ properties.put("max-record-size.phone", "10000");
|
|
|
+ properties.store(new FileOutputStream(propertyFile), "report properties updated on");
|
|
|
+ }
|
|
|
+ if(!properties.containsKey("use-xlsx")){
|
|
|
+ properties.put("use-xlsx", "false");
|
|
|
+ properties.store(new FileOutputStream(propertyFile), "report properties updated on");
|
|
|
+ }
|
|
|
+ if(!properties.containsKey("page.preview.show-export-buttons")){
|
|
|
+ properties.put("page.preview.show-export-buttons", "PDF, XLS, XLS_DATA");
|
|
|
+ properties.store(new FileOutputStream(propertyFile), "report properties updated on");
|
|
|
+ }
|
|
|
+
|
|
|
// 通过反射注入配置
|
|
|
Field[] declaredFields = getClass().getDeclaredFields();
|
|
|
for (Field declaredField : declaredFields) {
|