Java Config equivalent for conversionService / FormattingConversionServiceFactoryBean

后端 未结 1 441
暗喜
暗喜 2021-02-09 03:19

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

public class Order {

    @Id
    private int id;

    @NotNull
    private Date requestDate;

    @No         


        
1条回答
  •  独厮守ぢ
    2021-02-09 04:07

    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)
提交回复
热议问题