private static User yaml() throws IOException, JsonParseException, JsonMappingException {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
return mapper.readValue(new File("user.yaml"), User.class);
}
上面的代码特定于“用户”类
我想让它像这样通用,
private static <T> T yaml() throws IOException, JsonParseException, JsonMappingException {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
return mapper.readValue(new File("user.yaml"), T.class);
}
但是在 T.class 出现错误,有人可以提出建议吗?
爪哇
幕布斯7119047
相关分类