I am creating an external jar to add as a dependency to multiple spring boot projects. I am trying to make it auto configure itself to find and autowire a feign client. When the application attempts to start it fails with:
FeignConfiguration required a bean of type 'org.springframework.cloud.openfeign.FeignClientFactory' that could not be found.
External project pom.xml:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abc</groupId>
<artifactId>java-lib-feign-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>java-lib-feign-client</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.8</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>17</java.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>2020.0.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
</dependencies>
</project>
External project Feign Client:
@FeignClient("java-app-c")
public interface MyFeignClient {
@GetMapping("/")
public String get(@RequestParam(name = "name") String name);
External project Feign Configuration Class:
@Configuration
@EnableFeignClients(clients = MyFeignClient.class)
public class FeignConfiguration {
@Autowired
private MyFeignClient feignClient;
}
External project spring.factories file (src/main/resources/META-INF/spring.factories
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.abc.FeignConfiguration
For the EnableFeignClients annotation I have also tried using the base package of 'com.abc' but it doesn't change the result