Registering Built-In Property Editors in Spring 4 : CustomEditorConfigurer Example

A property editor is a feature of the JavaBeans API for converting property values to and from text values. Each property editor is designed for a certain type of property only. You may wish to employ property editors to simplify your bean configurations. In this tutorial, we will learn to configure spring’s build-in CustomDateEditor class […]

How to publish and listen application events in spring

Sometimes in your spring application, you may want to add capability of listening specific events so that you can process these events as per application logic. Examples of these events can be when a employee is added/ deleted; or a certain kind of transaction completed or rolled back. You can always write the event processing […]

Resolving Text Messages in Spring : ResourceBundleMessageSource Example

For an application to support internationalization, it requires the capability of resolving text messages for different locales. Spring’s application context is able to resolve text messages for a target locale by their keys. Typically, the messages for one locale should be stored in one separate properties file. This properties file is called a resource bundle. […]

How to load external resources / files into spring context?

Many times you would like to load external resources or files (e.g. text files, XML files, properties file, or image files) into your spring application context. Spring’s resource loader provides a unified getResource() method for you to retrieve an external resource by a resource path. Spring’s Resource Interface Resource is a general interface in Spring […]

Spring @Required Annotation and RequiredAnnotationBeanPostProcessor Example

In a production-scale application, there may be hundreds or thousands of beans declared in the IoC container, and the dependencies between them are often very complicated. One of the shortcomings of setter injection is that it’s very hard for you to check if all required properties have been set or not. To overcome this problem, […]

How to use Spring @Component, @Repository, @Service and @Controller Annotations?

In spring autowiring concepts, we learned about @Autowired annotation that it handles only wiring. You still have to define the beans themselves so the container is aware of them and can inject them for you. But with @Component, @Repository, @Service and @Controller annotations in place and after enabling automatic component scanning, spring will automatically import […]

Java blog for smart concepts and coding practices