whycxzp
2022-07-29 dc1081295f0fc60820fdbe67f534fa0e9af6b87d
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;
    }
}