ModelMapper: matches multiple source property hierarchies

后端 未结 4 939
孤城傲影
孤城傲影 2021-02-18 16:06

I cannot resolve modelMapper error. Do you have any ideas where is the issue?

NB: In view java.sql.Time doesn\'t have non-argument constructor I didn\'t find the better

4条回答
  •  抹茶落季
    2021-02-18 16:30

    I am not sure how it was with ModelMapper when question was asked but using converter should be straightforward. Instead of implementing a converter for the whole class implement it to the types that actually need conversion. So like:

    public static Converter timeConverter = new AbstractConverter<>() {
        @Override
        protected Time convert(LocalTime source) {
            return null == source ? null : Time.valueOf(source);
        }
    }; 
    

    Then it is just to:

    mm.addConverter(timeConverter);
    

    Guess if using Spring or EJB you know howto add this into your configuration.

提交回复
热议问题