springboot项目获取resource下的文件

package com.expr.exceldemo;

import org.springframework.core.io.ClassPathResource;

public class Test {
    public static void main(String[] args) {
        ClassPathResource classPathResource = new ClassPathResource("2019年4月园企业经营情况表(当月值).xlsx");
        boolean exists = classPathResource.exists();
        System.out.println(exists);
    }
}

代码中的那个excel就在项目的resource(资源文件夹下放着)。

猜你喜欢

转载自www.cnblogs.com/prader6/p/11307845.html