You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose, I've "client" app that has spring-boot-data-jpa with its automatic scan for Entity's and JpaRepository's in main app.
Also, there are two spring-boot-starters that "client" uses:
❯ first-starter
❯ second-starter
Both AutoConfiguration's [1, 2] contains @AutoConfigurationPackage annotation on top to add its Enity's and JpaRepository's to automatic scan in "client" service.
However, entity/repo from first-starter are added to AppContext, but entity/repo from the second one aren't, what we could see in appropriate test case.
I've tried a lot of different packages names in second-starter and still haven't identified any pattern.
For some names all is good, but for some – no.
The hours of debugging also didn't help to figure out the reason why package is cut off by name.
But It looks exactly like this ^))
You have provided no ordering for you auto-configuration classes so they fall back to being ordering alphabetically. This means that com.rost.starter.FirstStarterAutoConfiguration runs before org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration and its entities are found but ru.SecondStarterAutoConfiguration runs after it and its entities are not found.
To make things as robust as possible, both should be @AutoConfiguration(before = HibernateJpaAutoConfiguration.class). All three packages' entities are then found, as can be seen in the logs:
2025-03-20T21:52:32.474Z INFO 15546 --- [ main] o.h.m.i.EntityInstantiatorPojoStandard : HHH000182: No default (no-argument) constructor for class: dev.rost.autoconfigurationpackagesandbox.pets.Pet (class must be instantiated by Interceptor)
2025-03-20T21:52:32.489Z INFO 15546 --- [ main] o.h.m.i.EntityInstantiatorPojoStandard : HHH000182: No default (no-argument) constructor for class: ru.transport.Car (class must be instantiated by Interceptor)
2025-03-20T21:52:32.492Z INFO 15546 --- [ main] o.h.m.i.EntityInstantiatorPojoStandard : HHH000182: No default (no-argument) constructor for class: com.rost.starter.people.Person (class must be instantiated by Interceptor)
Rostik96
changed the title
@AutoConfigurationPackage unpredictable behavior depending on the package name
@AutoConfigurationPackage unpredictable behavior depending on a package name
Mar 20, 2025
Rostik96
changed the title
@AutoConfigurationPackage unpredictable behavior depending on a package name
@AutoConfigurationPackage unpredictable behaviour depending on package name
Mar 20, 2025
Hello, team!
My issue is intertwined with #19024.
Suppose, I've "client" app that has spring-boot-data-jpa with its automatic scan for Entity's and JpaRepository's in main app.
Also, there are two spring-boot-starters that "client" uses:
❯ first-starter
❯ second-starter
Theirs packages names consequently:
▹ com.rost.starter
▹ ru
Both AutoConfiguration's [1, 2] contains @AutoConfigurationPackage annotation on top to add its Enity's and JpaRepository's to automatic scan in "client" service.
However, entity/repo from first-starter are added to AppContext, but entity/repo from the second one aren't, what we could see in appropriate test case.
But...when I rename package
to, let's say,
It's starting to work!
I've tried a lot of different packages names in second-starter and still haven't identified any pattern.
For some names all is good, but for some – no.
The hours of debugging also didn't help to figure out the reason why package is cut off by name.
But It looks exactly like this ^))
So, tell me please, what's going on?
GitHub🔗
The text was updated successfully, but these errors were encountered: