|
@@ -1,8 +1,14 @@
|
|
|
package cn.com.qmth.examcloud.web.config;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.util.PathUtil;
|
|
|
+import cn.com.qmth.examcloud.web.support.ClasspathHelper;
|
|
|
+
|
|
|
|
|
|
* 系统配置
|
|
|
*
|
|
@@ -18,6 +24,26 @@ public class SystemConfig {
|
|
|
|
|
|
private String tempDataDir;
|
|
|
|
|
|
+
|
|
|
+ * 构造函数
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public SystemConfig() {
|
|
|
+
|
|
|
+ String classpath = ClasspathHelper.getClasspath();
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(dataDir)) {
|
|
|
+ String path = new File(classpath).getParent() + File.separator + "data";
|
|
|
+ dataDir = PathUtil.getCanonicalPath(new File(path));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(tempDataDir)) {
|
|
|
+ String path = new File(classpath).getParent() + File.separator + "temp";
|
|
|
+ tempDataDir = PathUtil.getCanonicalPath(new File(path));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public String getDataDir() {
|
|
|
return dataDir;
|
|
|
}
|