Friday 31 January 2014

Maven + Spring JPA Hibernate MySql Example

 In this example we will demonstrate how to use JPA in Spring framework in MySql Database.

Using Maven create a simple Java project structure.

Thursday 30 January 2014

Maven + Spring Hibernate MySql Example

Spring Hibernate MySql Example

In this example we will demonstrate how to use Hibernate in Spring framework in MySql Database.

Using Maven create a simple Java project structure.

Wednesday 29 January 2014

Spring MVC form handling example

In this tutorial, we show you how to develop a Spring MVC form handling example.


Monday 27 January 2014

Spring 3 MVC hello world example

In this tutorial, we show you how to develop a Spring 3 MVC hello world example.

Our goal is to create a basic Spring MVC application.

Technologies used :
  • Spring 3.0.5.RELEASE
  • JDK 1.6
  • Maven 3
  • Eclipse 3.6

Tuesday 14 January 2014

Spring 3 + Quartz 1.8.6 scheduler example

To integrate Spring with Quartz scheduler framework. Spring comes with many handy classes to support Quartz, and decouple your class to Quartz APIs


Monday 13 January 2014

Spring JdbcTemplate + JdbcDaoSupport example



Spring provides a simplification in handling database access with the Spring JDBC Template.
The Spring JDBC Template has the following advantages compared with standard JDBC.

  • The Spring JDBC template allows to clean-up the resources automatically, e.g. release the database connections.
  • The Spring JDBC template converts the standard JDBC SQLExceptions into RuntimeExceptions. This allows the programmer to react more flexible to the errors. The Spring JDBC template converts also the vendor specific error messages into better understandable error messages.

Wednesday 8 January 2014

Spring Object XML mapping example

converting Object to XML or vice verse. This process is also known as
  • XML Marshalling – Convert Object to XML.
  • XML UnMarshalling – Convert XML to Object.

Example show you how to use Spring’s oxm to do the conversion, Object <--> XML.

Spring’s oxm itself doesn’t handle the XML marshalling or UnMarshalling, it depends developer to inject their prefer XML binding framework. In this case, you will use Castor binding framework.

Tuesday 7 January 2014

Spring Security Login Form Using Database

In this tutorial we will see how to use database to perform the form-based login authentication in Spring Security.

Example 

Create Database Tables

We are using MySQL as database

create database for users to authenticate.
 

Spring AOP + AspectJ in XML configuration example

Spring AOP + AspectJ in XML configuration example

Monday 6 January 2014

Spring Expression Language using XML

The Spring Expression Language (SpEL for short) is a powerful expression language that supports querying and manipulating an object graph at runtime. The language syntax is similar to Unified EL but offers additional features, most notably method invocation and basic string templating functionality.

Spring Auto scanning components

Normally you declare all the beans or components in XML bean configuration file, so that Spring container can detect and register your beans or components.

Actually, Spring provides the capability of automatically detecting 'stereotyped' classes and registering corresponding BeanDefinitions with the ApplicationContext.

To autodetect these classes and register the corresponding beans requires the inclusion of the following element in XML where 'basePackage' would be a common parent package for the two classes (or alternatively a comma-separated list could be specified that included the parent package of each class).

Friday 3 January 2014

Spring Auto-Wiring Beans

In Spring framework, you can wire beans automatically with auto-wiring feature. To enable it, just define the “autowire” attribute in <bean>.

Spring Annotation Based Auto-Wiring


In Spring autowired bean via @Autowired, and it can be applied on setter method, constructor or a field.

See following full example to demonstrate the use of @Autowired.

Thursday 2 January 2014

Spring Resource Bundle With ReloadableResourceBundleMessageSource In Static Method

2 different ways to do this and one of them is a little bit harder to develop. I start with the hard way first, but in these examples you must need some environmental things:

My ResourcesBundle.properties file is directly inserted in the classpath.

My applicationContext.xml file is directly inserted in the WebContent/WEB-INF.