Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to customize the basePackages that auto-configurations consider (for example Spring Data Repositories) #27549

Closed
mdeinum opened this issue Aug 3, 2021 · 4 comments
Assignees
Labels
type: documentation A documentation update
Milestone

Comments

@mdeinum
Copy link
Contributor

mdeinum commented Aug 3, 2021

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 3, 2021
@snicoll
Copy link
Member

snicoll commented Aug 4, 2021

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

@snicoll snicoll added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 4, 2021
@snicoll snicoll added this to the 2.4.x milestone Aug 4, 2021
@snicoll snicoll changed the title Use scanBasePackages from @SpringBootApplication in @EntityScan, @EnableJpaRepositories etc. Document how to customize the basePackages that auto-configurations consider (i.e. Spring Data Repositories) Aug 4, 2021
@mdeinum
Copy link
Contributor Author

mdeinum commented Aug 5, 2021

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.

@wilkinsona wilkinsona modified the milestones: 2.4.x, 2.5.x Nov 18, 2021
@wilkinsona wilkinsona changed the title Document how to customize the basePackages that auto-configurations consider (i.e. Spring Data Repositories) Document how to customize the basePackages that auto-configurations consider (for example Spring Data Repositories) Jan 19, 2022
@wilkinsona wilkinsona modified the milestones: 2.5.x, 2.6.x May 19, 2022
@wilkinsona
Copy link
Member

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

@pnavato
Copy link

pnavato commented Feb 7, 2023

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 #19024 too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

5 participants