Spring 什么';@autoconfigurewebvc和@AutoConfigureMockMvc之间的区别是什么?

Spring 什么';@autoconfigurewebvc和@AutoConfigureMockMvc之间的区别是什么?,spring,spring-boot,spring-boot-test,Spring,Spring Boot,Spring Boot Test,在哪种情况下我应该使用每一个?@autoconfigurewebvc 如果需要为测试配置web层,但不需要,请使用此选项 需要使用MockMvc 它启用与web层和仅与web层相关的所有自动配置。这是整个自动配置的子集 它包括以下自动配置(请参阅) @AutoConfigureMockMvc 当您只想配置MockMvc 启用与MockMvc相关的所有自动配置,并且仅启用MockMvc。同样,这是整个自动配置的一个子集 它包括以下自动配置(请参阅) @WebMvcTest 除其他功能外,还包括@a

在哪种情况下我应该使用每一个?

@autoconfigurewebvc

如果需要为测试配置web层,但不需要,请使用此选项 需要使用
MockMvc

它启用与web层和仅与web层相关的所有自动配置。这是整个自动配置的子集

它包括以下自动配置(请参阅)

@AutoConfigureMockMvc

当您只想配置
MockMvc

启用与
MockMvc
相关的所有自动配置,并且仅启用
MockMvc
。同样,这是整个自动配置的一个子集

它包括以下自动配置(请参阅)

@WebMvcTest

除其他功能外,还包括
@autoconfigurewebvc
@AutoConfigureMockMvc

的可能重复项
# AutoConfigureWebMvc auto-configuration imports
org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc=\
org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration,\
org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration,\
org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration,\
org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration,\
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration,\
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\
org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration,\
org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration,\
org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\
org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\
org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration,\
org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration
# AutoConfigureMockMvc auto-configuration imports
org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc=\
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcAutoConfiguration,\
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcSecurityAutoConfiguration,\
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebClientAutoConfiguration,\
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebDriverAutoConfiguration