whycxzp
2022-09-05 d348ad3844d95c87d829be0cd910f41ed2a50e58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.whyc.dto;
 
import com.whyc.constant.YamlProperties;
import org.springframework.boot.system.ApplicationHome;
 
import java.io.File;
 
public class FileDirPath {
    //当前项目在dev和prod模式下访问路径
    public static String getFileDirName(){
        String fileDirName = "";
        ApplicationHome applicationHome = new ApplicationHome(FileDirPath.class);
        File jarFile = applicationHome.getDir();
        if( 1 == YamlProperties.runModel){
            fileDirName = jarFile.getParentFile().toString();
        }else{
            //打包版
            fileDirName = jarFile.toString();
        }
        return fileDirName;
    }
}