|
|
@@ -3,13 +3,17 @@ package com.uas.report;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.report.annotation.DynamicValue;
|
|
|
import com.uas.report.model.ExportType;
|
|
|
-import com.uas.report.util.*;
|
|
|
+import com.uas.report.util.FileUtils;
|
|
|
+import com.uas.report.util.ObjectUtils;
|
|
|
+import com.uas.report.util.ResourceUtils;
|
|
|
+import com.uas.report.util.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.lang.reflect.Field;
|
|
|
+import java.net.URL;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Properties;
|
|
|
@@ -130,7 +134,17 @@ public class DynamicProperties {
|
|
|
if (defaultPropertyFile == null) {
|
|
|
throw new FileNotFoundException("配置文件不存在:" + PROPERTY_FILE_NAME);
|
|
|
}
|
|
|
- FileUtils.copy(defaultPropertyFile, propertyFile);
|
|
|
+ // 是否以 spring boot jar 形式运行
|
|
|
+ URL location = getClass().getProtectionDomain().getCodeSource().getLocation();
|
|
|
+ if (org.springframework.util.ResourceUtils.isJarURL(location)) {
|
|
|
+ // 以 spring boot jar 形式运行时,不能直接复制默认配置文件,需以输入流的方式读取默认配置
|
|
|
+ InputStream inputStream = getClass().getResourceAsStream("/" + PROPERTY_FILE_NAME);
|
|
|
+ byte[] data = new byte[inputStream.available()];
|
|
|
+ inputStream.read(data);
|
|
|
+ FileUtils.write(propertyFile.getPath(), data);
|
|
|
+ }else{
|
|
|
+ FileUtils.copy(defaultPropertyFile, propertyFile);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if(propertyFile.isDirectory()){
|