Is there any way to load a entire folder with @Configuration files, the same way XML have: <import resource="folder/*.xml" />
, but with annotations?.
Asked
Active
Viewed 484 times
0

jfzr
- 374
- 4
- 17
2 Answers
2
The pendant of <import resource="folder/*.xml" />
but using configuration is @ImportResource
For example:
@Configuration
@ImportResource("folder/*.xml")
public class MyConfiguration {}

Nicolas Labrot
- 4,017
- 25
- 40
1
You could probably use component scanning.
@Configuration
@ComponentScan(basePackages = "org.example.configs")
public class Config {
}
All @Configuration classes from the org.example.configs
package will be included in the context.
Typesafe alternative:
// org.example.configs.SubConfig
@ComponentScan(basePackageClasses = SubConfig.class)

Prometheus
- 1,005
- 6
- 16