Hello everybody! I'm trying to update the project with Spring Boot 1.4.x on Spring Boot 2.0.6. But after loading dependencies and some fixes, two FeignClients are not being implemented from other projects. I tried to create a simple example using Spring Boot 2.0.6 and Spring Cloud Finchley.SR2 dependencies. In the example I created a simple FeignClient and try to implement it through the @Autowired annotation, but it does not work. There is an error that such a bin was not found. I searched a lot of examples and documentation of the spring, but it’s impossible to solve this problem in any way. Help someone in the know.

This is the controller:

@RequestMapping("/example") @RestController public class ExampleController { @RequestMapping(value = "/users", method = RequestMethod.GET) public String getUsers() { return "users"; } } 

This is FeignClient:

 @FeignClient("feign") public interface ExampleClient { @RequestMapping(value = "/feign/example/users", method = RequestMethod.GET) String users(); } 

This is the service where I want to implement the client:

 @Service public class CloudService { @Autowired private ExampleClient client; } 

It turns out that the client is not being introduced to the service for some reason. Though an example did under the documentation. Unclear.

This is pom:

 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.6.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.spboot</groupId> <artifactId>cloudexample</artifactId> <version>0.0.1-SNAPSHOT</version> <name>cloudexample</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> <spring-cloud.version>Finchley.SR2</spring-cloud.version> </properties> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-feign</artifactId> <version>1.3.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <version>2.0.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> <dependency> <groupId>io.github.openfeign</groupId> <artifactId>feign-httpclient</artifactId> </dependency> <dependency> <groupId>io.github.openfeign</groupId> <artifactId>feign-jackson</artifactId> <version>9.4.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310</artifactId> </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> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> <repositories> <repository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>https://repo.spring.io/milestone</url> </repository> </repositories> </project> 

And the main class itself:

 @SpringBootApplication @EnableFeignClients public class CloudexampleApplication { public static void main(String[] args) { SpringApplication.run(CloudexampleApplication.class, args); } } 
  • attach a piece of code regarding your problem to the body of the question. otherwise it is not clear what is wrong. - Senior Pomidor
  • @SeniorPomidor Added. - Alex Ciornii
  • try specifying @EnableFeignClients(basePackages = {"ExampleClient package"}) in CloudexampleApplication - Senior Pomidor
  • I tried. Does not help. Even if a concrete class I set no result in basePackageClasses. - Alex Ciornii am
  • added a method to CloudService; public String getusers() { return client.users(); } public String getusers() { return client.users(); } , in ExampleController added @Autowired CloudService cloudService; . registered cloudService.getusers () in mapping; and everything works. more precisely, there is no message that can not find a bean. - Senior Pomidor

1 answer 1

We found out that the problem was that Intellij IDEA was "stupid" and incorrectly showed the bins of the spring. Updated Intellij IDEA and the problem disappeared.