在微服务实验Springboot+Eureka+Reign时,需要将api服务的扫描到custom消费者端,
在启动类加上注解以后web访问失效
@ComponentScan(value ={"com.example.springcloudapi.*"})
发现加在主类以后会将默认的扫描覆盖掉,故而无法扫描除了com.example.springcloudapi.的其他包,导致某些服务无法生效,web请求也无法解析
只需要将扫描写到需要的类上即可
或者使用
@ComponentScans({@ComponentScan("com.xxx.springcloud.service")})
代替componentScan这种方法可以让@SpringBootApplication 和 多个 @ComponentScan(“com.leon.springcloud.service”) 共存。



