I'm an immigrant from JAX-RS to Spring.
With my following code,
@RequestMapping(method = RequestMethod.GET,
produces = {MediaType.APPLICATION_JSON_VALUE,
MediaType.APPLICATION_XML_VALUE})
public @ResponseBody ResponseEntity<List<Item>> read() {
final List<Item> body
= range(0, current().nextInt(1, 10))
.mapToObj(i -> Item.newRandomInstance())
.collect(toList());
return ResponseEntity.ok(body);
}
I get 200
for application/json
but 406
for application/xml
.
What is the best way to solve this problem?
Is there any functionality for automatic plural wrapping?
Here comes my dependencies
dependencies {
compile("org.springframework.boot:spring-boot-starter-web") {
// exclude module: "spring-boot-starter-tomcat"
}
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
// compile("org.springframework.boot:spring-boot-starter-jetty")
compile("org.springframework.boot:spring-boot-starter-actuator")
testCompile('org.springframework.boot:spring-boot-starter-test')
compile("org.springframework.boot:spring-boot-configuration-processor")
testCompile('com.jayway.jsonpath:json-path') // for gs-rest-service
// ----------------------------------------------------------------------------------------------- springfox-swagger
compile 'io.springfox:springfox-swagger2:2.7.0'
compile 'io.springfox:springfox-swagger-ui:2.7.0'
//compile('org.springframework.boot:spring-boot-starter-amqp') // rabbitmq
}