Assembling via Spring's Java Config
While classpath scanning is the cudgel of application assembly, Spring's Java Config is the scalpel. This approach is similar to the plain code approach introduced earlier in this chapter, but it's less messy and provides us with a framework so that we don't have to code everything by hand.
In this approach, we create configuration classes, each responsible for constructing a set of beans that are to be added to the application context.
For example, we could create a configuration class that is responsible for instantiating all of our persistence adapters:
@Configuration
@EnableJpaRepositories
class PersistenceAdapterConfiguration {
@Bean
AccountPersistenceAdapter accountPersistenceAdapter(
AccountRepository accountRepository,
ActivityRepository activityRepository,
...