Today encounter a problem very pit, feign injection failure.
Error message:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
12-18 15:29:57.654 ERROR [o.s.b.diagnostics.LoggingFailureAnalysisReporter] -
***************************
APPLICATION FAILED TO START
***************************
Description:
Field messageFeign in com.pance.scheduler.mdm.dataCenterTask.DataCenter required a bean of type 'com.pance.common.feign.MessageFeign' 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 'com.pance.common.feign.MessageFeign' in your configuration.
A very simple error message,
Looking directly at the Application, discovery, and contains annotations @EnableFeignClients, and @ComponentScan ( "com.pance"), and feign com.pance also included in the directory.
Check for a long time,
Finally, when most crashes, discovered a detail of the pit, when feign introduced in additional common package, although @ComponentScan ( "com.pance") specifies the scan path contains the path to feign, but if not feign under the same module, it is necessary to add their own scanning range, for example,
@EnableFeignClients(basePackages = "com.pance")
After adding, the problem is solved.
@EnableFeignClients(basePackages = "com.pance") @ComponentScan("com.pance") @EnableScheduling @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) public class SchedulerApplication { public static void main(String[] args) { /*only start one application*/ SpringApplication.run(SchedulerApplication.class, args); } }
=====================================
They are found online that you want to configure @EnableFeignClients, as well as the introduction of the jar package, but this basePackage this value with little explanation. Write your own stepped pit traumatic experience.