【发布时间】:2016-10-06 04:05:05
【问题描述】:
我想从另一个模块的/resources 目录读取/加载JSON 文件到当前模块并使用jackson 映射JSON。
当前模块名称为“transform”,而我需要的资源文件位于另一个名为“schema”的模块中。我在“转换”模块的pom.xml 文件中添加了“模式”作为maven dependency。
我需要在“schema”模块中读取/加载一个名为“example.json”的文件。
但我不断收到以下错误:
com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input.
到目前为止我所拥有的:
Map<String, String> map = objectMapper.readValue(
getClass().getClassLoader().getResourceAsStream("/schema/resources/example.json"),
new TypeReference<Map<String, String>>(){});
假设 example.json 的完整路径是“/schema/resources/example.json”。
【问题讨论】: