Developing Java Applications with Spring and Spring Boot
by Claudio Eduardo de Oliveira, Greg L. Turnquist, Alex Antonov
How it works...
As you can see, Spring gives us multiple ways of achieving the same thing and it all depends on our preference or particular details of the implementation.
We covered three different ways of adding HttpMessageConverter to our application. So what is the difference, one might ask?
Declaring HttpMessageConverter as @Bean is the quickest and simplest way of adding a custom converter to the application. It is similar to how we added servlet filters in an earlier example. If Spring detects a bean of the HttpMessageConverter type, it will add it to the list automatically. If we did not have a WebConfiguration class that implements WebMvcConfigurer, it would have been the preferred approach.
When the application needs to define a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access