当前位置:网站首页>ma.glasnost.orika. MappingException:No converter registered for conversion from Date to LocalDateTime
ma.glasnost.orika. MappingException:No converter registered for conversion from Date to LocalDateTime
2022-07-24 20:28:00 【Angry Apple ext】
background
- background
orika apiConvert to another type ofListobject , Fields fromDateToLocalDateTimeReport errors . - Detailed exception
ma.glasnost.orika.MappingException: No converter registered for conversion from Date to LocalDateTime, nor any ObjectFactory which can generate LocalDateTime from Date
at ma.glasnost.orika.impl.DefaultMapperFactory.lookupMapper(DefaultMapperFactory.java:726)
at ma.glasnost.orika.impl.MapperFacadeImpl.resolveMapper(MapperFacadeImpl.java:568)
at ma.glasnost.orika.impl.MapperFacadeImpl.resolveMappingStrategy(MapperFacadeImpl.java:178)
at ma.glasnost.orika.impl.DefaultBoundMapperFacade$BoundStrategyCache.getStrategy(DefaultBoundMapperFacade.java:259)
at ma.glasnost.orika.impl.DefaultBoundMapperFacade.map(DefaultBoundMapperFacade.java:137)
......
Solution
- Add converter .
import cn.hutool.core.date.DateUtil;
import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.MappingContext;
import ma.glasnost.orika.converter.BidirectionalConverter;
import ma.glasnost.orika.impl.DefaultMapperFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ma.glasnost.orika.metadata.Type;
import java.time.LocalDateTime;
import java.util.Date;
/** * @author Zhou Zhongqing * @description: towards Spring Register global objects for object replication * @date 2022/5/20 14:20 */
@Configuration
public class OrikaMapperFactoryConfig {
@Bean
public MapperFactory mapperFactory() {
return new DefaultMapperFactory.Builder().build();
}
@Bean
public MapperFacade mapperFacade() {
MapperFactory mapperFactory = mapperFactory();
// Date and LocalDateTime Mutual conversion of
mapperFactory.getConverterFactory().registerConverter(new OrikaDateConverter());
return mapperFactory.getMapperFacade();
}
/** * Date and LocalDateTime Mutual conversion of */
public class OrikaDateConverter extends BidirectionalConverter<Date, LocalDateTime> {
@Override
public LocalDateTime convertTo(Date source, Type<LocalDateTime> destinationType, MappingContext mappingContext) {
return DateUtil.toLocalDateTime(source);
}
@Override
public Date convertFrom(LocalDateTime source, Type<Date> destinationType, MappingContext mappingContext) {
String format = "yyyy-MM-dd HH:mm:ss";
String str = DateUtil.format(source, "yyyy-MM-dd HH:mm:ss");
return DateUtil.parse(str, format);
}
}
}
DateUtilIt useshutoolOf .
- When you meet
DateType toLocalDateTimeWill enterOrikaDateConverter#convertToMethod . As shown in the figure below .
convertFromThe method isDateType transferLocalDateTimeYou will use

- In this way, the conversion can be successful .
边栏推荐
- [msp430g2553] graphical development notes (2) system clock and low power consumption mode
- Each blogger needs to ask himself seven basic questions
- Opengl rendering pipeline
- Student achievement management system based on PHP
- [training Day9] rotate [violence] [thinking]
- Leetcode 1911. maximum subsequence alternating sum
- Pix2seq: Google brain proposes a unified interface for CV tasks!
- Software testing interview tips | if you don't receive the offer, I'll wash my hair upside down
- Synthesis route of ALA PNA alanine modified PNA peptide nucleic acid | AC ala PNA
- Lunch break train & problem thinking: thinking about the problem of converting the string formed by hour: minute: second to second
猜你喜欢

BGP - border gateway protocol
![[training Day10] point [enumeration] [bidirectional linked list]](/img/62/41dcab40eeb6aea545602e10c1c1a0.png)
[training Day10] point [enumeration] [bidirectional linked list]

In the era of new knowledge economy, who is producing knowledge?
![[training Day6] dream [priority queue] [greed]](/img/1b/309b53618b8a116862971799ce4e78.jpg)
[training Day6] dream [priority queue] [greed]

Generate self signed certificate: generate certificate and secret key

Apache atlas version 2.2 installation

VLAN Technology

Make Huawei router into FTP server (realize upload and download function)

(posted) differences and connections between beanfactory and factorybean

Google's display of Chrome browser icons was abandoned, and it was intended to be a small rocket
随机推荐
"Hualiu is the top stream"? Share your idea of yyds
Valdo2021 - vascular space segmentation in vascular disease detection challenge (3)
Pix2seq: Google brain proposes a unified interface for CV tasks!
How to view the execution plan of a stored procedure in Youxuan database
TCP sliding window, singleton mode (lazy and hungry) double checked locking / double checked locking (DCL)
Apache atlas version 2.2 installation
What should Ali pay attention to during the interview? Personal account of Alibaba interns who passed five rounds of interviews
Azide labeled PNA peptide nucleic acid | methylene blue labeled PNA peptide nucleic acid | tyrosine modified PNA | Tyr PNA Qiyue Bio
Lunch break train & problem thinking: on multidimensional array statistics of the number of elements
Leetcode 48 rotating image (horizontal + main diagonal), leetcode 221 maximum square (dynamic programming DP indicates the answer value with ij as the lower right corner), leetcode 240 searching two-d
Appium obtains and clicks coordinates, which is very easy to use when elements are inconvenient to locate
Todolist case
Alibaba sentinel basic operation
[sciter]: window communication
Connect the smart WiFi remote control in the home assistant
Do you want to enroll in a training class or study by yourself?
Leetcode 560 and the subarray of K (with negative numbers, one-time traversal prefix and), leetcode 438 find all alphabetic ectopic words in the string (optimized sliding window), leetcode 141 circula
Safe way -- Analysis of single pipe reverse connection back door
Teach you five ways to crack the computer boot password
The difference between delete, truncate and drop in MySQL