Spring Rest POST Json RequestBody Content type not supported

后端 未结 14 1661
粉色の甜心
粉色の甜心 2020-12-05 05:58

When I try to post new object with post method. RequestBody could not recognize contentType. Spring is already configured and POST could work with others objects, but not th

14条回答
  •  渐次进展
    2020-12-05 06:51

    So I had a similar issue where I had a bean with some overloaded constructor. This bean also had Optional properties.

    To resolve that I just removed the overloaded constructors and it worked.

    example:

    public class Bean{
    
    Optional string;
    Optional object;
    
    public Bean(Optional str, Optional obj){
    string = str;
    object = obj;
    }
    
    ///The problem was below constructor
    
    public Bean(Optional str){
    string = str;
    object = Optional.empty();
    }
    
    
    
    }
    
    }
    

提交回复
热议问题