hello! what is the preferred way to structure vari...
# spring
d
hello! what is the preferred way to structure various configuration files, e.g. given some common configuration beans is it better to
Copy code
@Configuration @Import([A, B])
class TopLevelConfig {
  // uses beans from A/B
  // defines beans used commonly by A and B
}
or
Copy code
@Configuration
class CommonConfig { // common beans }

@Configuration @Import(CommonConfig)
class A

@Configuration @Import(CommonConfig)
class B

@Configuration @Import([A, B])
class TopLevelConfig { // use beans from A/B }
basically is there any issue with importing same config multiple times
m
what is toplevelConfig do for?
d
Just organizes the imports and is the entry point for auto config
In 1 it also defines common beans for a/b (extracted to CommonConfig in 2)
s
Do you even need the imports? wont class A automatically detect CommonConfig, unless you are not using default auto configuration settings?
d
it is a library so cannot rely on auto config
afaik auto config should be configured only at an app level