用弹簧启动从Itis中获取Json对象

我尝试从Itis Webservice获取Json对象(https://www.itis.gov/ITISWebService/jsonservice/getHierarchyUpFromTSN?tsn=164282)。 我使用下面的类来存储Json对象:

public class Genus {

     @JsonProperty("tsn")
    private int tsn;

     @JsonProperty("taxonName")
    private String taxonName;

    public Genus() {
        super();
    }

    public int getTsn() {
        return tsn;
    }
    public void setTsn(int tsn) {
        this.tsn = tsn;
    }
    public String getCombinedName() {
        return taxonName;
    }
    public void setCombinedName(String taxonName) {
        this.taxonName = taxonName;
    }   

    @Override
    public String toString() {
        return "Genus [tsn=" + tsn + ", taxonName=" + taxonName + "]";
    }
} 

我的主要方法:

    public static void main(String[] args) {
            RestTemplate restTemplate = new RestTemplate();
            Genus quote = restTemplate.getForObject("https://www.itis.gov/ITISWebService/jsonservice/getHierarchyUpFromTSN?tsn=164282", Genus.class);
             System.out.println(quote.toString());
}

结果我得到以下异常:

线程“main”异常org.springframework.web.client.RestClientException:无法提取响应:没有找到合适的HttpMessageConverter用于响应类型[class de.aquaristikguru.taxonomy.itisObjects.Genus]和内容类型[text / json; charset = ISO-8859-1

我该如何解决它?

链接地址: http://www.djcxy.com/p/48189.html

上一篇: Get Json object from Itis with spring boot

下一篇: How to change response http header in get request by spring RestTemplate?