我想在 MockMvc bean 的帮助下测试我的 Spring Boot 微服务的/health
端点。 但就我而言,server.port
和management.server.port
属性具有不同的值。 我的MockMvc
发出的GET
请求总是在server.port
中定义的端口上结束。
那里已经有一个答案:
设置管理端口
时弹簧靴的执行器不可用,但我在Spring Boot 2.2.2
找不到这个ManagementContextResolver
类。
到目前为止,我发现"管理"ConfigurableWebServerApplicationContext
是在org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration.DifferentManagementContextConfiguration
中创建的,但我不明白如何获得对它的引用。
试试这个,它来自 SpringBoot Docs:
@WebIntegrationTest({"server.port=8080", "management.port=8090"})