I have a Spring Boot application (using Spring Boot 2.4.11) where I'm using Spring Integration. I added the org.springframework.boot:spring-boot-starter-integration
and hence I expected @IntegrationComponentScan
to be active by default. Indeed, I find Issue 2037 that seems to suggest this. Also, I see that annotation on org.springframework.boot.autoconfigure.integration.IntegrationAutoConfigurationScanRegistrar.IntegrationComponentScanConfiguration
.
However, my @MessagingGateway
annotated interfaces were not taken up by Spring. I tried to add an explicit @IntegrationComponentScan
on one of my @Configuration
classes, but it didn't work either.
It started to work once I also specified an explicit basePackages
value for that annotation, so:
@Configuration
@IntegrationComponentScan(basePackages = "com.example.app.integration")
public class MyConfigurationClass {
}
and of course my annotated interfaces are in a package below com.example.app.integration
.
Am I missing something? I couldn't find any reference to @IntegrationComponentScan
in Spring Boot documentation. Other similar annotations (like @EnableJpaRepositories
for Spring Data or @EntityScan
) are not strictly necessary, unless you need to customize the scanning scope.
I also found Issue 3375, that seems to suggest that I should look at @AutoConfigurationPackage
, but:
- I can't find any mention to this annotation in Spring Boot documentation
- I suspect this will apply to ANY other "scan" annotation enabled by Spring Boot, so my
basePackages
in this case must probably point to some package very close to the "root" of my application - why isn't this annotation required by other
@*Scan
annotations like the above ones?