A Spring bean is an object created, configured, dependency-injected, and lifecycle-managed by the Spring IoC container. Beans form the backbone of a Spring application, while the framework controls when application code is called. section 14.1
A bean participates in an application through several container responsibilities:
- Combines application classes with configuration metadata to assemble a ready-to-run application. section 14.1
- Creates objects and injects them where application components require them. section 14.1
- Allows an @Bean method to expose a constructed object for management and injection. section 16.2
- Supports startup configuration by registering an ApplicationRunner bean whose method runs before SpringApplication.run completes. section 16.2
Loading an auction as a bean
A CsvDataLoader class can define buildAuctionFromCsv() with @Bean. The method constructs an Auction, reads users from a CSV file, and returns the object. An application importing CsvDataLoader can autowire the resulting Auction and use it while an ApplicationRunner saves its users through UserRepository. section 16.2
Shows how the Spring IoC container combines application classes and configuration information to create a ready-to-run application. section 14.1


