首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >查找并定义一个具体的org.springframework.web.reactive.function.client.WebClient

查找并定义一个具体的org.springframework.web.reactive.function.client.WebClient
EN

Stack Overflow用户
提问于 2020-08-26 05:49:48
回答 1查看 32关注 0票数 0

如何注册以下接口的具体实现(通过applicationcontext.xml) (xml配置)?

代码语言:javascript
复制
org.springframework.web.reactive.function.client.WebClient

“指定的类是一个接口”

https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/reactive/function/client/WebClient.html

代码语言:javascript
复制
public interface WebClient

完整代码

代码语言:javascript
复制
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.reactive.function.client.WebClient;

import javax.inject.Inject;

public class MyClientProxy implements IMyClientProxy {

    private final WebClient webClient;

    private static Logger LOGGER;


    public MyClientProxy(Logger lgr, WebClient webClient) {
        if (null == lgr) {
            throw new IllegalArgumentException("Logger is null");
        }
        this.LOGGER = lgr;

        if (null == webClient) {
            throw new IllegalArgumentException("WebClient is null");
        }
        this.webClient = webClient;
    }
}

导入

代码语言:javascript
复制
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-webflux
compile group: 'org.springframework.boot', name: 'spring-boot-starter-webflux', version: '2.3.1.RELEASE'

显然,这是行不通的

(来自applicationcontext.xml)

代码语言:javascript
复制
    <bean id="zzzWebClientBean"
          class="org.springframework.web.reactive.function.client.WebClient">
    </bean>

但在“我尝试过的”类别中...

EN

回答 1

Stack Overflow用户

发布于 2020-08-26 06:15:38

好吧,这是一个工厂静态方法。

代码语言:javascript
复制
    <bean id="zzzWebClientBean"
          class="org.springframework.web.reactive.function.client.WebClient" factory-method="create">
    </bean>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63587594

复制
相关文章

相似问题

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