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.

SpringJavaConfigExample

5. Run the test program.

 

OUTPUT:

 

Download  Source Code

Posted in Spring and tagged , , .

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">