I have a java class as writtten below:
@RequiredArgsConstructor
public class Interceptor implements RequestInterceptor {
@Value("${spring.application.name}")
private final String applicationName;
}
and this class is used by a client:
@FeignClient(
name = "interceptor",
url = "${interceptor.url}",
configuration = Interceptor.class
)
public interface InterceptorApiClient {
}
The problem is, when I try to run the project, I am getting this error:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.String' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at app//org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1801)
at app//org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1357)
at app//org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)
at app//org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)
at app//org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
... 181 more
I put @Component annotation, give @PropertySource({"classpath:application.yaml"}) but nothing changed.
Note: The applicationName is in application.yaml file like this:
spring:
application:
name: interceptor-project
any idea?