我正在尝试使用 Spring Traverson 和基本的 restTemplate 使用休息 Web 服务,但它不起作用......
我使用了一个返回的休息网络服务:
获取 /books/1 内容类型:应用程序/hal+json { “标题”:“悲惨世界”, “国际标准书号”:“9780685113974”, “_嵌入”:{ “作者”: { "firstName": "维克多", "姓氏": "雨果" , “出生”:“18020226”, “死”:“18850522” }, “元”:{ “类型”:“经典”, “国家”:“法国” } } }
我想在 Java 端拥有如下所示的资源类:
class Book {
String title;
String isbn;
Author author;
Meta meta;
}
class Author {
String firstName;
String lastName;
Date born;
Date died;
}
class Meta {
String type;
String country;
}
如何使用带有 Resource、Resources 或 ResourceSupport 类的 RestTemplate 或 Traverson 来匹配这些 java 对象?