转:草丛里的码农的获取类路径方式集合
String springbooPath1 = ClassUtils.getDefaultClassLoader().getResource("").getPath();
System.out.println("springbooPath1:"+springbooPath1);
String springbooPath2 = ResourceUtils.getURL("classpath:").getPath();
System.out.println("springbooPath2:"+springbooPath2);
Properties properties = System.getProperties();
String dir = properties.getProperty("user.dir");
System.out.println("dir:"+dir);
String realPath = properties.getProperty("uploadFilePath");
System.out.println("uploadFilePath:"+realPath);
String protectionDomain = 当前Controller名称.class.getProtectionDomain().getCodeSource().getLocation().getFile();
System.out.println("protectionDomain:"+protectionDomain);
String classPath = this.getClass().getResource("").getPath();
System.out.println("classPath:"+classPath);
String classPath2 = this.getClass().getResource("/").getPath();
System.out.println("classPath2:"+classPath2);
String classLoaderPath = 当前Controller名称.class.getClassLoader().getResource("").getPath();
System.out.println("classLoaderPath:"+classLoaderPath);
URL contextClassPath1 = Thread.currentThread().getContextClassLoader().getResource("");
System.out.println("contextClassPath1:"+contextClassPath1.getPath());