需要慢慢看的东西

public class BaseBO implements Serializable {
    @Override
    public String toString() {
        return ToStringUtils.toString(this);
    }
}
@Slf4j
public class ToStringUtils {

    private ToStringUtils() {
    }

    public static String toString(Object obj) {
        try {
            return JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue);
        } catch (Exception e) {
            String objName = obj.getClass().getName() + "@" + Integer.toHexString(obj.hashCode());
            log.error("{} toString exception (exception only log, not throw out): {}", objName, e.getMessage(), e);
            return objName;
        }
    }

}

猜你喜欢

转载自my.oschina.net/u/3142419/blog/1807690