小编brm*_*rmd的帖子

没有符合条件的 bean,预期有一个匹配的 bean,但找到了 2 个

我在互联网和堆栈溢出上进行了搜索,但似乎无法找到解决我的问题的方法:

Unable to find bean reference for type 'class com.consol.citrus.http.client.HttpClient'Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.consol.citrus.http.client.HttpClient' available: expected single matching bean but found 2: server1BasicAuthClient,server2BasicAuthClient
Run Code Online (Sandbox Code Playgroud)

概述一些背景信息:我必须使用 Spring 5 和 Citrus Framework 制作一个小型应用程序来自动化我们的集成测试。

我定义为遵循我的 Beans:

@Configuration 
public class EndpointAuthentication {

public String server1Host;

public int server1Port;

public String server2Host;

public int server2Port;

@Bean(name="server1BasicAuthClient")
public com.consol.citrus.http.client.HttpClient server1BasicAuthClient() throws Exception {
    return CitrusEndpoints.http()
            .client()
            .requestUrl(String.format("http://%s:%s/", server1Host, server1Port))
            .requestFactory(sslRequestFactory(server1Host,server1Port))
            .build();
}

@Bean(name="server2BasicAuthClient")
public com.consol.citrus.http.client.HttpClient server2BasicAuthClient() throws Exception {
    return CitrusEndpoints.http()
            .client()
            .requestUrl(String.format("http://%s:%s/", …
Run Code Online (Sandbox Code Playgroud)

java spring hibernate spring-boot citrus-framework

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

citrus-framework ×1

hibernate ×1

java ×1

spring ×1

spring-boot ×1