When adding an external library to Spring Boot with a different base package structure than your Spring Boot based application, a pattern emerges in the form of additional annotations to detect components, entities, repositories etc.

@SpringBootApplication(scanBasePackages= { "package1", "package2",...})
@EntityScan("package1", "package2",...})
@EnableJpaRepositories("package1", "package2", ...})
public class FooApplication { ... }

Or maybe even all packages added through an @ComponentScan to be included (unless explicitly specified that is).

This could be reduced if the scanBasePackages property was taken into account in places like the @EntityScan, auto- configuration of Spring Data Repositories etc.

Comment From: snicoll

That's what AutoConfigurationPackage is for but it would deserve a bit more love in the doc.

Comment From: mdeinum

Now that is an annotation that I didn't already know (and it already exists since Spring Boot 1.3). This has been a well-kept secret. I might take the time and write a small blog post on it.

Comment From: wilkinsona

We should update @EntityScan at the same time to make it clear that using it will result in @AutoConfigurationPackage being ignored.

Comment From: pnavato

We should update @EntityScan at the same time to make it clear that using it will result in @AutoConfigurationPackage being ignored.

Yes, just for reference: this has been already discussed in https://github.com/spring-projects/spring-boot/issues/19024 too.