无法使用trip advisor rest api中的数据

时间:2015-06-26 20:07:42

标签: java rest spring-mvc

我在我的java代码中集成了TripAdvisor Rest API以获取酒店详细信息。我正在发出一个get请求,并尝试在类DataDataforHotel

的对象中保存返回数据
public static final String SERVICE_URL = "http://api.tripadvisor.com/api/partner/2.0/location/5069632?key=<user-key>";

RestTemplate restTemplate = new RestTemplate(); 
TripAdvisorDataforHotel  obj = restTemplate.getForObject(SERVICE_URL, TripAdvisorDataforHotel.class); 

类TripAdvisorDataforHotel:

@JsonIgnoreProperties(ignoreUnknown = true)
public class TripAdvisorDataforHotel {

    private String see_all_photos;
    private int num_reviews;
    private String name;
    private String[] awards;
    private String rating_image_url;
    private String price_level;
    private int photo_count;
    private String location_string;
    private String web_url;
    private  Ranking_data ranking_data;
    private Subratings[] subratings;
    private String[] cuisine;
    private int percent_recommended;
    private String longitude;
    private Ancestors[] ancestorses;
    private String write_review;
    private Reviews[] reviewses;
    private Trip_types[] trip_types;
    private int rating;
    private String latitude;
    private String location_id;
    private Address_Obj address_obj;
    private  String[] review_rating_count;
    private  Category category;
    private  Subcategory subcategory;

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public Subcategory getSubcategory() {
        return subcategory;
    }

    public void setSubcategory(Subcategory subcategory) {
        this.subcategory = subcategory;
    }

    public Subratings[] getSubratings() {
        return subratings;
    }

    public void setSubratings(Subratings[] subratings) {
        this.subratings = subratings;
    }

    public String[] getReview_rating_count() {
        return review_rating_count;
    }

    public void setReview_rating_count(String[] review_rating_count) {
        this.review_rating_count = review_rating_count;
    }

    public String getSee_all_photos() {
        return see_all_photos;
    }

    public void setSee_all_photos(String see_all_photos) {
        this.see_all_photos = see_all_photos;
    }

    public int getNum_reviews() {
        return num_reviews;
    }

    public void setNum_reviews(int num_reviews) {
        this.num_reviews = num_reviews;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String[] getAwards() {
        return awards;
    }

    public void setAwards(String[] awards) {
        this.awards = awards;
    }

    public String getRating_image_url() {
        return rating_image_url;
    }

    public void setRating_image_url(String rating_image_url) {
        this.rating_image_url = rating_image_url;
    }

    public String getPrice_level() {
        return price_level;
    }

    public void setPrice_level(String price_level) {
        this.price_level = price_level;
    }

    public int getPhoto_count() {
        return photo_count;
    }

    public void setPhoto_count(int photo_count) {
        this.photo_count = photo_count;
    }

    public String getLocation_string() {
        return location_string;
    }

    public void setLocation_string(String location_string) {
        this.location_string = location_string;
    }

    public String getWeb_url() {
        return web_url;
    }

    public void setWeb_url(String web_url) {
        this.web_url = web_url;
    }

    public Ranking_data getRanking_data() {
        return ranking_data;
    }

    public void setRanking_data(Ranking_data ranking_data) {
        this.ranking_data = ranking_data;
    }


    public String[] getCuisine() {
        return cuisine;
    }

    public void setCuisine(String[] cuisine) {
        this.cuisine = cuisine;
    }

    public int getPercent_recommended() {
        return percent_recommended;
    }

    public void setPercent_recommended(int percent_recommended) {
        this.percent_recommended = percent_recommended;
    }

    public String getLongitude() {
        return longitude;
    }

    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }

    public Ancestors[] getAncestorses() {
        return ancestorses;
    }

    public void setAncestorses(Ancestors[] ancestorses) {
        this.ancestorses = ancestorses;
    }

    public String getWrite_review() {
        return write_review;
    }

    public void setWrite_review(String write_review) {
        this.write_review = write_review;
    }

    public Reviews[] getReviewses() {
        return reviewses;
    }

    public void setReviewses(Reviews[] reviewses) {
        this.reviewses = reviewses;
    }

    public Trip_types[] getTrip_types() {
        return trip_types;
    }

    public void setTrip_types(Trip_types[] trip_types) {
        this.trip_types = trip_types;
    }

    public int getRating() {
        return rating;
    }

    public void setRating(int rating) {
        this.rating = rating;
    }

    public String getLatitude() {
        return latitude;
    }

    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }

    public String getLocation_id() {
        return location_id;
    }

    public void setLocation_id(String location_id) {
        this.location_id = location_id;
    }

    public Address_Obj getAddress_obj() {
        return address_obj;
    }

    public void setAddress_obj(Address_Obj address_obj) {
        this.address_obj = address_obj;
    }
}

但是gettingError ::

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class com.sucl.tripAdvisor.Address_Obj] and content type [text/javascript;charset=utf-8]
    at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:110)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:576)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:529)
    at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:236)
    at com.sucl.controller.TripAdvisorRestTesting.testgetTripadvisorData(TripAdvisorRestTesting.java:24)
    at com.sucl.controller.TripAdvisorRestTesting.main(TripAdvisorRestTesting.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

0 个答案:

没有答案