Httpmessagenotwritableexception: No Converter Found for Return Value of Type: Class Java.Util.Hashmap in Spring MVC

HttpMessageNotWritableException: No converter for [...] with preset Content-Type 'null'] with OpenApi Spring generator

The spring generator discriminates against xml by default, see the documentation: https://openapi-generator.tech/docs/generators/spring under

Option  | Description                                       | Default
--------+---------------------------------------------------+---------
withXml | whether to include support for application/xml | false
| content type and include XML annotations in the |
| model (works with libraries that provide support |
| for JSON and XML) |

org.springframework.http.converter.HttpMessageNotWritableException No converter found for return value of type: class

I just encountered this issue today and spent several hours to figure out what the issue is. Almost all of the answers I've seen are either because of missing getters and setters, adding the fasterxml dependency into the pom. I already have getters and setters and the tutorial I was following did not require those pom changes.

mariotepro's solution is what got me past the issue. His solution is buried under the comments so I decided to put it here in the answer so people can easily see it in case they have the same scenario.

So yes, just to reiterate, going into my maven repo and deleting the fasterxml folder and re-running maven is what fixed the issue for me.



Related Topics



Leave a reply



Submit