The example above shows the basic concept of dependency injection, the MessagePrinter is decoupled from the MessageService implementation, with Spring Framework wiring everything together.
This is example from http://projects.spring.io/spring-framework/ and my article in russian https://smartcoderteam.github.io/what-is-spring-framework-and-example-of-di/
- Run Application.java from your favorite IDE
- Spring Framework 4.3.3 For DI
- Maven for build
Just 3 classes