2.jar包环境下,java代码里面读取项目配置文件(我的项目是springboot),这么写:
public static final String CLIENT_CONFIG_FILE = "fdfs_client.conf";
(一)//jar包环境下
String fdfsClientConfigFilePath = System.getProperty("user.dir") + File.separator + CLIENT_CONFIG_FILE;
(二)//在eclipse那种编译环境中
//这种方式jar包环境下为null
String classPath = new File(FileManager.class.getResource("/").getFile()).getCanonicalPath();
String fdfsClientConfigFilePath = classPath + File.separator + CLIENT_CONFIG_FILE;