Tag Archives: Spring IoC

Spring 3 Java Config Example


via Spring 3 Java Config Example | Examples Java Code Geeks.

With this example we are going to demonstrate how to use Spring 3.2.3 Java Configuration. Java Configuration provides a pure-Java means of configuring the Spring container. By taking advantage of Java language features such as annotations and generics, Java Configuration allows users to express configuration logic and metadata directly in code, alleviating any need for XML. With Java Configuation, bean definition and Spring configuration is moved out of XML configuration file into a Java class.

A @Configuration annotated class consists of @Bean annotated methods that define instantiation, configuration, and initialization logic for objects to be managed by the Spring IoC container.

Our preferred development environment is Eclipse. We are using Eclipse Juno (4.2) version, along with Maven Integration plugin version 3.1.0. You can download Eclipse from here and Maven Plugin for Eclipse from here. The installation of Maven plugin for Eclipse is out of the scope of this tutorial and will not be discussed. We are also using Spring version 3.2.3 and the JDK 7_u_21.

Let’s begin,