java - 查找和 DI 定义一个具体的 org.springframework.web.reactive.function.client.WebClient
问题描述
如何注册以下接口的具体实现(通过 applicationcontext.xml)(xml 配置)?
org.springframework.web.reactive.function.client.WebClient
“指定的类是一个接口”
public interface WebClient
完整代码
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;
}
}
进口
// 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)
<bean id="zzzWebClientBean"
class="org.springframework.web.reactive.function.client.WebClient">
</bean>
但在“我尝试过的”类别中......
解决方案
好的,这是一个工厂静态方法。
<bean id="zzzWebClientBean"
class="org.springframework.web.reactive.function.client.WebClient" factory-method="create">
</bean>
推荐阅读
- reactjs - 关闭 React 模式并提交
- mysql - Group by - 不显示 Group NULL 和控制记录
- reactjs - 表单提交后如何清除输入?
- graphql - GraphQL:标准过滤参数还是标准过滤参数?
- java - 无法使用 spring 的 SchedulerFactoryBean 配置石英线程
- git - 可以复制现在从 GitHub 弃用的“网络图”功能(可能在 git 中)吗?
- google-cloud-platform - 从 GCE 中运行的脚本查看张量板输出
- r - R 中的整理:如何根据向量将我的二进制列折叠成字符?
- python - 删除 yaml 文件中的元素
- angular - 将带有本地存储项目列表的文本文件保存到本地计算机