我的feignclient :
@FeignClient(value = "order-server", qualifiers = "order-server", fallback = OrderEcFallbackService.class)
public interface OrderEcService {
......省略
}
我的controller:
@RestController
@RequestMapping(value = "/driver/order/ec")
@PreAuthorize("isAuthenticated()")
@Api(tags = "司机快车订单相关接口")
public class DriverOrderEcController {
@Qualifier("order-server")
@Autowired
private OrderEcService orderEcService;
......省略
}
启动时报错:
2021-07-26 09:38:44.746 WARN 18592 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [RxIoScheduler-1 (Evictor)] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@11.0.4/jdk.internal.misc.Unsafe.park(Native Method)
java.base@11.0.4/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:234)
java.base@11.0.4/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2123)
java.base@11.0.4/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
java.base@11.0.4/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
java.base@11.0.4/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
java.base@11.0.4/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
java.base@11.0.4/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base@11.0.4/java.lang.Thread.run(Thread.java:834)
2021-07-26 09:38:44.749 DEBUG 18592 --- [ main] .c.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: unknown
Error creating bean with name ‘driverController‘: Unsatisfied dependency expressed through field ‘orderEcService‘; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.cloudease.driver.service.OrderEcService‘ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations:
{@org.springframework.beans.factory.annotation.Qualifier(value="order-service"), @org.springframework.beans.factory.annotation.Autowired(required=true)}
根据多方排查,代码没有问题,接口没有问题,
最后发现,问题在于feignclient的名字上面,
order服务的名字是: order-service,
我上面配置的是: order-server,
导致无法装配feignclient..
这问题也是醉了,完全想不到是这一块的问题,还是同事提醒一下我才发现.
主要是 之前可以启动,但是order-service的服务名称被改掉了,我这里没做相应的修改,所以报错了.