spring-projects / spring-data-commons

Spring Data Commons. Interfaces and code shared between the various datastore specific implementations.
https://spring.io/projects/spring-data
Apache License 2.0
771 stars 671 forks source link

Make Repository available in CDI 4 environment by default #2818

Open hantsy opened 1 year ago

hantsy commented 1 year ago

I remember there is an old issue about this topic, now Jakarta EE 10/CDI 4 is switched to use annotated discovery mode by default to scan beans.

But Spring Data Repository still requires using all discovery mode (the default mode in the legacy CDI 1.x/2.x) to treat Spring Data Repository as CDI beans in a Jakarta container, such as WildFly, Payara, Glassfish etc.

mp911de commented 1 year ago

The current workaround is having bean-defining annotations on repositories. IIRC, there's no hook in CDI that would allow scanning for subtypes of a particular interface.

hantsy commented 1 year ago

Spring Data Repositories are not regular CDI beans, as a developer, when we use this feature(repository as CDI beans) in WildFly like other none CDI components(such as EJB, Jaxrs Controllers, etc.), I hope it is enabled by default.

Spring Data itself already scanned the completed repository metadata, and CDI allow manually registering beans like this, Spring Boot can provide a property to enable/disable the CDI bean registration.