我添加了一个用于Instant
< =>Long
的couchbase转换器,但是在读取该值时出现错误。Couchbase转换器弹簧数据混淆整数长
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.Integer] to type [java.time.Instant]
我的转换器看起来像这样
@WritingConverter
public enum InstantToLongConverter implements Converter<Instant, Long> {
INSTANCE;
public Long convert(Instant source) {
return source == null ? null : source.getEpochSecond();
}
}
@ReadingConverter
public enum LongToInstantConverter implements Converter<Long, Instant> {
INSTANCE;
@Override
public Instant convert(Long source) {
return source == null ? null : Instant.ofEpochSecond(source);
}
}
我应该只使用整型? 这是一个错误?