Java Config equivalent for conversionService / FormattingConversionServiceFactoryBean

后端 未结 1 442
暗喜
暗喜 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)
提交回复
热议问题