Showing posts from October, 2009

When to use value tag and value attribute?

A bean can be configured using either value attribute/tag, constructor injection. We should use value tag only when we need to configure a property instance variable in a class, else we should avoid it. Below is an example


Spring Basics

1) Loading properties from a properties file in spring application
In Spring we have two ways of managing our application beans (a) BeanFactory and (b) ApplicationContext. BeanFactory provides basic functionality regarding bean management services whereas ApplicationContext provides more functionalities along with features provided by BeanFactory.

To read a property from (.properties) file we should use ApplicationContext, we can not use BeanFactory because it does not have access to applcation resources. In this article we'll see how we can access properties from a property file:

(a) spring configuration file - appliaction-context.xml