首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WebTestClient配置了错误的端口

WebTestClient配置了错误的端口
EN

Stack Overflow用户
提问于 2020-06-29 04:32:17
回答 1查看 401关注 0票数 2

我用Spock编写了集成测试。已将Spring引导上下文配置为随机端口。Documantation声称,然后sprig应该向我注入正确配置的WebTestClient实例,但是当我试图调用那些“自动配置的实例时,我有下面的错误:

代码语言:javascript
复制
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: localhost/127.0.0.1:8080
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
    |_ checkpoint ⇢ Request to POST http://localhost:8080/sign-up [DefaultWebClient]

下面是我的代码: BaseIntegrationTest

代码语言:javascript
复制
@SpringBootTest(webEnvironment = RANDOM_PORT, classes= Application.class)
@ContextConfiguration
@EnableConfigurationProperties
abstract class BaseIntegrationSpec extends Specification {

使用WebTestClient类:

代码语言:javascript
复制
@Component
class WebTestClientWrapper {

    @Autowired
    private WebTestClient webTestClient

    @Autowired
    private ObjectMapper objectMapper
EN

回答 1

Stack Overflow用户

发布于 2020-07-06 06:40:39

确保在开始测试时localhost:8080上的服务器已经在运行。WebTestClient假定外部服务器在绑定到服务器时正在运行。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62627911

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档