Java Config equivalent for conversionService / FormattingConversionServiceFactoryBean

后端 未结 1 983
闹比i
闹比i 2021-02-09 03:49

I have an entity that contains another entity, as follows:

public class Order {

    @Id
    private int id;

    @NotNull
    private Date requestDate;

    @No         


        
1条回答
  •  梦毁少年i
    2021-02-09 04:20

    All you need to do in your case is:

    @Configuration
    public class MvcConfig extends WebMvcConfigurerAdapter{
    
        @Autowired
        private OrderTypeConvertor orderTypeConvertor;
    
        ...
    
        @Override
        public void addFormatters(FormatterRegistry registry) {
            registry.addConverter(orderTypeConvertor);
        }
    }
    

    0 讨论(0)
提交回复
热议问题