This project demonstrates the core concepts of Dependency Injection (DI) using plain Java, Spring Core, and Spring Boot.
- Created
PrinterandUserServiceclasses. - Demonstrated constructor-based and setter-based injection.
- No Spring involved — just Java wiring.
- Added Spring Core dependency to a Maven project.
- Annotated components with
@Component. - Used
AnnotationConfigApplicationContextto retrieve beans.
- Bootstrapped project using Spring Initializr.
- Created a simple REST controller (
GreetingController) with a "Hello, Spring Boot!" endpoint.
- Demonstrated how to exclude
DataSourceAutoConfiguration. - Confirmed that no H2 DB starts when excluded.
- Used
application.propertiesandapplication-dev.yml. - Bound configuration using
@ConfigurationProperties("app"). - Exposed
/titleendpoint to return configured title.
- Created interface
TimeServicewith two implementations:SystemTimeService(marked@Primary)MockTimeService(annotated with@Qualifier("mock"))
- Injected into a
TimeController.
Check docs/annotations.md for:
- Sample output screenshots
- Console logs
- Controller outputs
- Configuration files
- Java 17+
- Spring Core
- Spring Boot
- Maven