The reason why the data format returned by Spring Boot is XML instead of JSON is explored and solved

Question :

The controller class annotated with @RestController expects the returned data format to be JSON, but the actual return is indeed in XML format. As shown below:
insert image description here

Scenario :

It was normal at the beginning of the creation of the Spring Boot project, but after the introduction of the Spring Cloud-related dependency package spring-cloud-starter-netflix-eureka-server, this problem occurred.

		<dependency>
		    <groupId>org.springframework.cloud</groupId>
		    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
		    <version>3.0.5</version>
		</dependency>

Reason and analysis :
The controller class annotated with @RestController returns the response body annotated with @ResponseBody. The default format is JSON, but it can also be in other formats, such as XML.
Spring Boot uses jackson to process data in JSON format by default, but if jac is introduced in the project

Guess you like

Origin blog.csdn.net/oscar999/article/details/124240607