Skip to content

OpenFeign in another module #1479

@yerzhant

Description

@yerzhant
id("org.springframework.boot") version "3.5.7"
id("io.spring.dependency-management") version "1.1.7"

extra["springCloudVersion"] = "2025.0.0"
extra["springModulithVersion"] = "1.4.3"

When a project has an OpenFeign in it (implementation("org.springframework.cloud:spring-cloud-starter-openfeign")) and a feign client is in some module, other than a testing one, then when one does a module test (@ApplicationModuleTest), then the test fails with an exception:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.openfeign.aot.FeignClientBeanFactoryInitializationAotProcessor]: Factory method 'feignClientBeanFactoryInitializationCodeGenerator' threw exception with message: No bean named 'some.package.SmsCenter' available
	at app//org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:200)
	at app//org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiateWithFactoryMethod(SimpleInstantiationStrategy.java:89)
	at app//org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:169)
	at app//org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
	... 31 more

But if it (the module, containing the feign interface) is added to the test scope (@ApplicationModuleTest(extraIncludes = ["sms"])), then the test passes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions