I have an error when I inject feignClient interface in my service. This is a spring boot and spring cloud version that I use:
org.springframework.boot:spring-boot-starter-parent:2.0.6.RELEASE spring cloud version : Finchley.SR2
But when I create a feignclient bean in my class service it works.
Create a customer feign client:
@Component("DepartmentClient")
@FeignClient(name = "DEPARTMENT-SERVICE", url = "http://test")
public interface DepartmentClient {
@RequestMapping(value = "/department/{departmentId}", method = RequestMethod.GET)
void findDepartmetById(@PathVariable("departmentId") int departmentId);
}
I inject this feign client in the service like
@Service
public class AgentService {
Logger logger = LoggerFactory.getLogger(AgentService.class);
@Autowired
private AgentRepository agentRepository;
@Autowired
private DepartmentClient departmentClient;
....
}
Output
Field departmentClient in ...AgentService required a bean of type '...DepartmentClient' that could not be found.
The injection point has the following annotations:
org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type .... DepartmentClient' in your configuration.