spring-projects / spring-projects/spring-boot

Allow adding packages to entity scanning without disabling the default scanning

Open
#30,064 13 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

I would like to provide a library that adds JPA entities to the persistence context bootstrapped. Ideally I would like to achieve that without the user having to explicitly configure @EntityScan to include the package of that library solely by registering some auto configuration.

I've tried both @EntityScan on a configuration class and a BeanDefinitionRegistryPostProcessor to trigger EntityScanPackages.register(…) but EntityScanner will only apply the autoconfiguration package as fallback if no entity package is configured at all.

I can see that the semantics of @EntityScan are supposed to stay unchanged. I'd be fine with a programmatic approach, so maybe an explicit method EntityScanPackage.registerAdditional(…) could populate an additional list that EntityScanner adds on top of the defaulted base list?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading EntityScanPackages.register(…) and EntityScanner, focusing on how the autoconfiguration package is used as a fallback when no entity package is configured. The change would need to preserve @EntityScan semantics while allowing additional packages to be registered and included alongside the default base package; no specific test file is mentioned.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.