spring javaconfig example – @Configuration

In this tutorial we are going to explore how we can achieve to build a completely XML-free sample Spring  application.

Before Spring 3.0  we are using XML based approach to configure our beans in xml file. But in Spring 3.0 we have new feature “@Configuration”  which is useful to configure our beans in programmatically. let us have a example …


1. Create a Maven project and add Spring  Dependencies in eclipse.

2. Write Spring bean class

3. Write a java Configuration class which have configuration of  bean class.

This is the configuration file( instead of writing xml configuration) where we need to configure all the bean classes regarding the application.

4. Project Structure in Eclipse.


5. Run the test program.




Download  Source Code

Posted in Spring and tagged , , .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.