Read file from resources folder in Spring Boot

后端 未结 12 1088
盖世英雄少女心
盖世英雄少女心 2020-11-28 06:50

I\'m using Spring Boot and json-schema-validator. I\'m trying to read a file called jsonschema.json from the resources folder. I\'ve t

12条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 07:30

    stuck in the same issue, this helps me

    URL resource = getClass().getClassLoader().getResource("jsonschema.json");
    JsonNode jsonNode = JsonLoader.fromURL(resource);
    

提交回复
热议问题