//获取跟目录
String pathPrefix = ResourceUtils.getURL("classpath:").getPath();
File file = new File(pathPrefix);
if(!file.exists()) file = new File("");
System.out.println("file path:"+file.getAbsolutePath());
//获取文件可以直接如下
//File file = new File("classpath: static/images/test.png");
//如果上传目录为/static/images/upload/,则可以如下获取:
File upload = new File(file.getAbsolutePath(),"static/images/upload/");
if(!upload.exists()) upload.mkdirs();
System.out.println("upload url:"+upload.getAbsolutePath());
//在开发测试模式时,得到的地址为:{项目跟目录}/target/static/images/upload/