|
@@ -3,6 +3,9 @@ package cn.com.qmth.print.manage.config;
|
|
import cn.com.qmth.print.manage.controller.ExamController;
|
|
import cn.com.qmth.print.manage.controller.ExamController;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @Description:
|
|
* @Description:
|
|
* @Author: CaoZixuan
|
|
* @Author: CaoZixuan
|
|
@@ -11,23 +14,23 @@ import org.springframework.stereotype.Component;
|
|
@Component
|
|
@Component
|
|
public class SysProperty {
|
|
public class SysProperty {
|
|
|
|
|
|
- private String tempDataDir = initTempDataDir();
|
|
|
|
|
|
+ private String tempDir = initTempDataDir();
|
|
|
|
|
|
- public static String initTempDataDir(){
|
|
|
|
|
|
+ public static String initTempDataDir() {
|
|
ClassLoader classLoader = ExamController.class.getClassLoader();
|
|
ClassLoader classLoader = ExamController.class.getClassLoader();
|
|
// 步骤 2:获取当前类的所在路径
|
|
// 步骤 2:获取当前类的所在路径
|
|
- String path = classLoader.getResource("").getPath();
|
|
|
|
|
|
+ String path = Objects.requireNonNull(classLoader.getResource("")).getPath();
|
|
// 步骤 3:定位到项目的根目录
|
|
// 步骤 3:定位到项目的根目录
|
|
String rootPath = path.substring(0, path.indexOf("/target"));
|
|
String rootPath = path.substring(0, path.indexOf("/target"));
|
|
// 打印根目录路径
|
|
// 打印根目录路径
|
|
- return rootPath;
|
|
|
|
|
|
+ return new File(rootPath).getParent() + "/temp";
|
|
}
|
|
}
|
|
|
|
|
|
- public String getTempDataDir() {
|
|
|
|
- return tempDataDir;
|
|
|
|
|
|
+ public String getTempDir() {
|
|
|
|
+ return tempDir;
|
|
}
|
|
}
|
|
|
|
|
|
- public void setTempDataDir(String tempDataDir) {
|
|
|
|
- this.tempDataDir = tempDataDir;
|
|
|
|
|
|
+ public void setTempDir(String tempDir) {
|
|
|
|
+ this.tempDir = tempDir;
|
|
}
|
|
}
|
|
}
|
|
}
|