新Demo里面hms.json是什么文件,为何运行程序会报错
新demo运行出错,报错如图显示hms.json下载出错,是什么原因呢
public class HmsJsonUtil {
private static ObjectMapper mapper;
@Autowired
public void setMapper(ObjectMapper mapper) {
HmsJsonUtil.mapper = mapper;
}private static JsonNode nodes;
private HmsJsonUtil(){
}
@PostConstruct
private void loadJsonFile() {
try (InputStream inputStream = new ClassPathResource("hms.json").getInputStream()){
nodes = mapper.readTree(inputStream);
} catch (IOException e) {
log.error("hms.json failed to load.");
e.printStackTrace();
}
}public static HmsMessage get(String key) {
return mapper.convertValue(nodes.get(key), HmsMessage.class);
}
}
Please sign in to leave a comment.
Comments
1 comment