博主
258
258
258
258
专辑

第四节 使用HuTool工具读取Resource下文件

亮子 2023-11-25 14:43:03 6931 0 0 0
 @ApiOperation("ClassPath单一资源访问类:在classpath下查找文件")
    @GetMapping("/classPath")
    public CommonResult classPath() throws IOException {
        //获取定义在src/main/resources文件夹中的配置文件
        ClassPathResource resource = new ClassPathResource("generator.properties");
        Properties prop = new Properties();
        prop.load(resource.getStream());
        LOGGER.info("/classpath:{}",prop);
        return CommonResult.success(null,"操作成功!");
    }