@EnableFeignClients package scan - spring boot

3.3k views Asked by At

I have annotated spring boot application with Feign Client

@SpringBootApplication
@EnableFeignClients({"com.ms.Foo1.api", "com.ms.Foo2.api",
"com.ms.Foo3.api", "com.ms.Foo4.api", "com.ms.Foo5.api", "com.ms.Foo6.api",
"com.ms.Foo7.api", "com.ms.Foo8.api", "com.ms.Foo9.api", "com.ms.Foo10.api"})
public class AnalyticsApplication extends SpringBootServletInitializer {
}

everything working fine, AS I just modify the bases packages. its start scanning package outside the api.

@SpringBootApplication
@EnableFeignClients({"com.ms.*.api"})
public class AnalyticsApplication extends SpringBootServletInitializer {
}

I am expecting that @EnableFeignClients({"com.ms.*.api"}) will scan only clients inside the api but it start scanning outside the api package as well.

what I need to change ? or can we apply regex here instead of mention every package ?

1

There are 1 answers

0
Francesc Recio On

You can use a regex filter on @ComponentScan like this:

@ComponentScan(basePackages = "com.ms",
     includeFilters = @Filter(type = FilterType.REGEX, pattern="com.ms.*.api"))
public class AnalyticsApplication extends SpringBootServletInitializer {
}

But @EnableFeignClients haven't this feature. The only thing you can do is:

@EnableFeignClients(basePackages = "com.ms")
public class AnalyticsApplication extends SpringBootServletInitializer {
}