Combined Eureka and Configuration Server Returns XML
See original GitHub issueI am migrating our Spring Cloud application from Angel.SR3 to Brixton.M3. Currently, we have combined the config server and the eureka server into a single app:
@SpringBootApplication
@EnableConfigServer
@EnableEurekaServer
public class DepbugApplication {
public static void main(String[] args) {
SpringApplication.run(DepbugApplication.class, args);
}
}
I have set “spring.cloud.config.server.prefix” to “configuration”
In the Angel.SR3 release:
http://host:port/eureka/apps is returned as XML. http://host:port/configuration/appname/profile is returned as JSON
In the Brixton.M3 release:
http://host:port/eureka/apps is returned as XML. http://host:port/configuration/appname/profile is returned as XML
I believe this is because the eureka maven artifact has a runtime dependency on jackson-dataformat-xml which is then picked up by Spring Boot.
I am able to get the JSON version of the configuration by suffixing the URL with .json but JSON really should be the default/only format for the configuration end points.
In looking at the content negotiation in Spring MVC, it looks like this could be fixed by adding
produces={“application/json”} to the @RequestMapping for the various config server end points.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:11 (6 by maintainers)
Found the culprit by accident 😃 It’s the cloud starter for eureka!
To fix the issue just use this:
Additional Information:
Chrome is sending the following in its Http Request Header:
I was able to work around this issue by extending the WebMvcConfigurerAdapter and telling the content negotiation to ignore the accept header and default to JSON: