Spring 豆子';用户服务.FeignClientSpecification';,在null中定义,无法注册
我正在启动微服务并抛出以下错误:Spring 豆子';用户服务.FeignClientSpecification';,在null中定义,无法注册,spring,Spring,我正在启动微服务并抛出以下错误: *************************** APPLICATION FAILED TO START *************************** Description: The bean 'soa-user-service.FeignClientSpecification', defined in null, could not be registered. A bean with that name has already been
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'soa-user-service.FeignClientSpecification', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
我知道更改覆盖配置可能会解决此问题。但我想知道有没有其他方法可以避免这个问题。更改覆盖配置只是为了避免问题,可能无法解决安全问题。我需要在一个微服务中定义多个外部客户端,因为我想在多控制器中对我的服务api进行分类,我的控制器如下所示:
@RequestMapping(value="/soa/login")
@FeignClient(name = "soa-user-service")
public interface ILoginController {
}
@RequestMapping(value="/soa/login")
@FeignClient(name = "soa-user-service")
public interface IUserController {
}
如果我将所有api放在一个控制器中,那么这个控制器api太长而且不可读。我的问题是:在一个微服务中有更好的方法避免多控制器冲突吗
附言:
Greenwich.SR1
2.1.4.1发布
是的,有一个解决方案,您可以将属性“contextId”添加到注释@FeignClient,并为每个控制器赋予不同的值
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
<spring-boot.version>2.1.4.RELEASE</spring-boot.version>