Need help?

Our experts will login to your server within 30 minutes to fix urgent issues.

Customer support or server support, make your own solution using our support configuration wizard.

Spring: A Lightweight Application Framework for Day-to-Day business applications

What is Spring?

Spring is a Lightweight Application Framework which covers all levels of your day-to-day business applications. It helps you write, debug and maintain enterprise applications much easier and faster. It can also be integrated with other commonly used frameworks and greatly simplify your development work.

Why Use Spring?

Spring is an important integration technology and focuses mainly on providing a way to manage your business objects.
It has the capacity to leverage services from underlying runtime environment like J2EE Services. Spring is unique, for several reasons:

  • Spring is an ideal framework for test driven projects.
  • It is comprehensive and modular. It has dynamic nature. For example, you might choose it to simplify your JDBC calls or use it to manage all your business objects.
  • The Spring Portfolio , a solution for enterprise Java development is based on the Spring Framework.

Spring Architecture

Back to Top

Spring Features

Spring includes:

  • A customized abstraction layer for transactions and managing those transactions. It does so by allowing pluggable transaction managers. This makes it easy to divide and separate transactions, thus track down the issues faster.
  • A JDBC Abstraction Layer. This helps in troubleshooting errors and reduces the amount of code need to be written.
  • A layer for integrating with the toplink technologies like Hibernate, JDO, and iBATIS SQL Maps. This is in terms of resource holders, DAO implementations and support.
  • Gives highly integrated features for AOP.
  • A customizable and flexible MVC web application framework which is built on core Spring functionality. It can be highly configured and also accommodates multiple view technologies like JSP, Velocity, Tiles, iText, and POI. It can also be easily configured as a middle tier and integrate this with any other web MVC framework based web tier. Eg: Struts, WebWork, or Tapestry.
  • License: All Spring projects are licensed under the terms of the Apache License, Version 2.0.
Back to Top

Beans

This a basic sturcture of XML-based configuration Metadata :


<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

Setter Injection :

Java Bean Definition- Type #1
public class BeanClass1 {
 private BeanClass2 beanClass2;

 public setBeanClass2(BeanClass2 beanClass2) {
 this.beanClass2 = beanClass2;
 }
}

Corresponding relation mappings- Type #1

<bean id="beanClass1" class="BeanClass1">

 <property name="beanClass2" ref="beanClass2" />

</bean>

Constructor Injection :

Java Bean Definition- Type #2:
public class BeanClass1{

 public BeanClass1(BeanClass2 beanClass2){
 this.beanClass2=beanClass2;
 }

}
Corresponding relational mappings- Type #2:

<bean id="beanClass1" class="BeanClass1" >

 <constructor-arg>
 <bean class="BeanClass2" />
 <!-- OR -->
 <ref bean="beanClass2" />
 </constructor-arg>

 <constructor-arg type="java.lang.Integer" value="450" />
 </bean>
 <constructor-arg>
</bean>

Basic XML terms :

    • <bean> – Bean class name

 

    • <property> -Injecting dependencies of a bean

 

    • <constructor-arg>- Constructor Injection

 

    • <ref> – Bean Reference

 

    • id – indicates an unique name to refer in the Manager/DAO classes

 

    • class – indicates the class to refer/instatntiate.

 

    • type- of the argument

 

    • value- injecting the value of the argument

 

Back to Top

Configuring Spring & Hibernate in Eclipse

Steps for Installing Hibernate & Spring Plugins in Eclipse:

  • Add the remote url for these plugins in eclipse
    Help->Software Update->Find Install
  • Select the “Search For New Features to install” and click Next
  • Click the New RemoteSite and enter the name (e.g.Hibernate)and the below url
    http://download.jboss.org/jbosside/updates/development/
  • Repeat the above steps for the below url.
    http://dist.springframework.org/release/IDE/site.xml
  • Select both the check boxes
  • Enter the finish button and choose the plugins needed from the list.
  • Accept the license (if any) and start downloading.
  • Once the download is complete, it will prompt for installing the plugins. Press “install all” button.
  • Once the installation is complete, restart the eclipse. Your Hibernate plugin is now enabled.
  • Eclipse will be having some heap size problems while launching or after opening. In order to avoid those, use the below command:
    eclipse -vmargs -Xmx1024m -Xms384m -XX:MaxPermSize=192m
    
    Xmx - maximun RAM size
    Xms - minimun RAM size
    XXMaxPermSize - Virtual Machine memory allocation.

Note: Use eclipse Europa 3.x version

Back to Top

Reference

Home Page:

Tutorials:

    • A complete tutorial for Spring 2.5.x:

https://static.springframework.org/spring/docs/2.5.x/reference/beans.html

    • For other versions of spring

http://static.springframework.org/spring/docs/

Spring Forum:

http://forum.spring.io/

Hibernate Forum

Hibernate Home page:

Eclipse Home Page:

Spring IDE:

  • http://springide.org/project
Back to Top


About the author:

Girish Kodupurath, a Senior Software Engineer at Bobcares, working since January 2007. He is a SCJP certified Java developer and also has experience in developing web based PHP applications. His major achievement lies in the contribution to the open source project VTONF. He is passionate in writing parsing scripts and JAVA programs.



Java

1 Comment

  1. Thanks for comprehensive explanation.
    Really it is helpful to configure eclipse with spring and hibernate

    joxon

Bobcares
Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.
MORE ABOUT BOBCARES