我应该将 Jackson 的 ObjectMapper 声明为静态字段吗?
Jackson 库的类似乎是线程安全的。ObjectMapper
这是否意味着我应该像这样声明my为静态字段ObjectMapper
class Me {
private static final ObjectMapper mapper = new ObjectMapper();
}
而不是像这样作为实例级字段?
class Me {
private final ObjectMapper mapper = new ObjectMapper();
}