Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that SpringBoot integrates Eureka and causes the returned result to change from json to xml?

2025-02-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article Xiaobian introduces in detail for you "SpringBoot integration Eureka causes the return result from json to xml how to solve", the content is detailed, the steps are clear, and the details are handled properly. I hope that this "SpringBoot integration Eureka leads to return results from json to xml how to solve" article can help you solve doubts, following the editor's ideas slowly in-depth, together to learn new knowledge.

SpringBoot integration with Eureka causes the returned result to change from json to xml solution

Add to the requested Mapping

Produces = {"application/json;charset=UTF-8"}

For example:

@ GetMapping (value = "/ user-instance", produces = {"application/json;charset=UTF-8"})

Here are json and xml

@ GetMapping (value = "/ user-instance", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ GetMapping (value = "/ user-instance", produces = MediaType.APPLICATION_XML_VALUE) supports returns in both JSON and XML formats

Sometimes the project requires two return formats, so all we have to do is add the dependency of jackson xml

Com.fasterxml.jackson.jaxrs jackson-jaxrs-xml-providereureka startup failure returns xml message 1. Why do you need this?

Today, after starting eclipse as usual, starting the eureka project, visiting the corresponding eureka returned a lot of xml information, but looking at the console did not report an error. Oddly enough, du Niang could not even find the relevant information. There is a similar problem on google. Here is a hint to add a line of configuration in the configuration file. I tried and still failed.

II. Solutions

After trying various methods to no avail, I decided to start with maven.

For the first time, find the storage path under your maven configuration, (windows-preference-maven-user settings local repository)

Enter org/ springframework, delete the cloud folder (need to close eclipse), then open eclipse, update the project, and start eureka again after completion, the problem is still not solved, all the problems are not the cloud package.

The second time, very ruthlessly, delete the entire springframework folder directly and download it again. Success. Eureka access returned to normal.

Read this, the "SpringBoot integration of Eureka caused by the return result from json to xml how to solve" article has been introduced, want to master the knowledge of this article also need to practice and use in order to understand, if you want to know more about the article, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report