0

我创建了一个简单的 Reacting Feign Client

@ReactiveFeignClient(name = "mechanic-service", path = "${mechanic.service.url}")
public interface MechanicClient {
    @GetMapping("/mechanic-api/hello")
    Mono<HelloWorldDetails> hi();
}

现在,当我在我的服务类中 @Autowire 时,IntelliJ 给出了一个错误:

无法自动接线。找不到“MechanicClient”类型的 bean。

这是我的主要课程:

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@EnableReactiveFeignClients
public class CustomerApplication {
    public static void main(String[] args) {
        SpringApplication.run(CustomerApplication.class, args);
    }
}

pom.xml

<properties>
        <java.version>17</java.version>
        <feign-reactor.version>3.1.1</feign-reactor.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
        <dependency>
            <groupId>com.playtika.reactivefeign</groupId>
            <artifactId>feign-reactor-spring-cloud-starter</artifactId>
            <version>${feign-reactor.version}</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

当我启动服务器时,出现以下错误:

org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为“helloWorldController”的bean时出错:通过字段“mechClient”表示的依赖关系不满足;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为 'com.emech.customer.config.feign.MechanicClient' 的 bean 时出错:FactoryBean 在创建对象时抛出异常;嵌套异常是 java.lang.IllegalStateException: No bean found of type interface reactivefeign.ReactiveFeignBuilder for mechanic-service at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660) ~[spring-beans -5.3.10.jar:5.3.10] 在 org.springframework.beans.factory.annotation。

谁能指导我,我缺少什么,我是 Reactive Feign Client 的新手。谢谢

4

0 回答 0