使用 WebClient 的 Spring Cloud 函数 AWS Lambda

问题描述

我有一个使用 Spring Cloud Functions 创建的 Spring Boot 应用程序。应用程序使用 Spring Web Flux - WebClient 调用一个容器化服务。

在本地运行时,一切正常。当我使用 AWS Lambda Adapter 构建并部署到 AWS 时。我收到以下异常。

Unable to start reactive web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ReactiveWebApplicationContext due to missing ReactiveWebServerFactory bean.: org.springframework.context.ApplicationContextException
org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ReactiveWebApplicationContext due to missing ReactiveWebServerFactory bean.
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh(ReactiveWebServerApplicationContext.java:81)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:582)
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:63)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767)

我做错了什么。我最初忽略了 AWS jar 构建

<configuration>
    <artifactSet>
        <excludes>
            <exclude>org.springframework.cloud:spring-cloud-function-web</exclude>
        </excludes>
    </artifactSet>
</configuration>

然后删除它,然后也尝试使用

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-function-webflux</artifactId>
        </dependency>

网络客户端

        WebClient webClient = WebClient.builder()
          .exchangeStrategies(ExchangeStrategies.builder()
                    .codecs(configurer -> configurer
                      .defaultCodecs()
                      .maxInMemorySize(16 * 1024 * 1024))
                    .build())
          .build();

仍然没有快乐。

这可能吗。如果有任何帮助,将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)