【问题标题】:test spring cloud GateWay by MockMvc can't initialize a bean of type 'WebApplicationContext'通过 MockMvc 测试 spring cloud GateWay 无法初始化“WebApplicationContext”类型的 bean
【发布时间】:2020-09-28 08:40:20
【问题描述】:

主要问题描述如下 [a bean of type 'org.springframework.web.context.WebApplicationContext' that could not be found]

我尝试了很多次,并且猜测添加一个 spring-boot-web-starter 可能会起作用,但是当我这样做时,又出现了另一个问题。

【问题讨论】:

标签: testing junit spring-cloud gateway mockmvc


【解决方案1】:

你不能在 Spring Cloud Gateway 中使用基于 servlet 的解决方案,因为它是基于反应器的。请使用 WebFlux 启动器而不是 spring-boot-web-starter

【讨论】:

  • 非常感谢。还有任何工具可以在访问 url 时测试网关的响应,就像 MockMVC 测试基于 servlet 的 Web 应用程序一样?
猜你喜欢
  • 2015-09-27
  • 1970-01-01
  • 1970-01-01
  • 2016-08-08
  • 2021-03-30
  • 2014-03-01
  • 2021-03-29
  • 1970-01-01
  • 2023-03-12
相关资源
最近更新 更多