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-startersecond-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

ru.transport

to, let's say,

ez

It's starting to work!

\ I've tried a lot of different packages names in second-starter is and still haven't identified any pattern. For some names all is good, but for some – no.

The debug clock also did not help to find a piece of code where the package is cut off by name. But It looks exactly like this ^))

So, tell me please, what's going on?

GitHub🔗

Comment From: wilkinsona

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)

Comment From: Rostik96

Dear @wilkinsona, thank you for the quick and clear clarification, sir🤝 Receiving a reply directly from you is a milestone for me!✨