I am writing a Boot starter where I have some JPA repositories in foo.jpa. I want to add auto-configuration in foo.jpa.autoconfigure, but the only way to get the repositories auto-configured with the usual Boot scanning is to use @AutoConfigurationPackage, and @AutoConfigurationPackage does not take any arguments.
Parallel with annotations such as @ComponentScan, @AutoConfigurationPackage should take basePackage and basePackageClasses arguments to specify a different root package(s) to be incorporated.
Comment From: wilkinsona
I don't think you need any arguments to achieve what you want. For example, an auto-configuration class in foo.jpa.autoconfigure could @Import a class in foo.jpa that is annotated with @AutoConfigurationPackage. Perhaps a little cumbersome, but it should allow you to achieve what you want.
Comment From: chrylis
That would require a configuration class in each external package, correct? The main reason that I'm concerned about this is that while I'm still on classpath, that's not an option with modules.
Comment From: wilkinsona
You'd need a configuration class in each base package. What do you mean by external? From your description above I understood that the foo.jpa and foo.jpa.autoconfigure packages were both in the same starter.
Comment From: chrylis
The intention was to have a foo-feature package and a foo-feature-starter package, with the starter containing exactly the Spring Boot auto-configuration pieces.
Comment From: philwebb
We'll investigate this for 2.3.x. In the meantime you can probably call AutoConfigurationPackages directly (see AutoConfigurationPackages.Registrar for an example).