Is there any Spring boot documentation to understand how web mvc configuration works?

I’ll find out a solution for setting Jackson ( Jackson2ObjectMapperBuilder to allow ANY field to be visible ) by trial and error.

And there are some questions about this:

  • Why doesn't this work until I delete @EnableWebMvc?
  • Why @Beandoesn't it work if I put it in a class @Configurationextended from WebMvcConfigurerAdapter?

I set a breakpoint on the main constructors ObjectMapper, MappingJackson2HttpMessageConverterand found mvc in a simple spring boot web application

ObjectMapper created 9 times!

MappingJackson2HttpMessageConverter created 8 times!

Why? and why @Autowiredfor ObjectMapper?

This whole question can be expressed in one thing: are there any documents to find out how all these configurations work together?

+1
source share
2 answers

Why it doesn't work until I delete @EnableWebMvc

When you use @EnableWebMvc, you tell Spring Boot that you want to have full control over the configuration of Spring MVC. This is described in Spring's download help documentation , which states that "the easiest way to get full control over your MVC configuration is to provide your own @Configurationwith annotation @EnableWebMvc. This will leave the entire MVC configuration in your hands."

ObjectMapper, MappingJackson2HttpMessageConverter Spring - mvc

ObjectMapper 9 !

MappingJackson2HttpMessageConverter 8 !

?

ObjectMapper MappingJackson2HttpMessageConverter Spring MVC ( ). Spring .

@Autowired ObjectMapper?

Autowiring Spring beans. Spring bean, .

: - , , ?

Spring . @EnableWebMvc, , , , . , , , @Autowired, Spring Framework.

+3

Source: https://habr.com/ru/post/1584119/


All Articles