Create a maven project with quick-start template, refer to this post in case you don’t know how to create one. Next, open the pom.xml and enter these spring dependencies which will be used by our sample app.

Next, We’ll make a class to configure it in the spring container as bean to use. Let’s create a class that will simply print out the Poem, First we create an interface “Poem”

And the concrete implementing class

Next, add the spring config file in the class path (APPLICATION_ROOT/src/main/resources/spring-config.xml) to configure SimplePoem bean in it like:

Finally, let’s put the Main class to fire up the code: