Spring – applicationContext.xml configuration

October 5, 2009 in IT and Stuff

It is my first time to configure my web application to use spring framework.

So, first time we create a applicationContext.xml under the WEB-INF folder. Below is the basic configuration

< ?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

In the contexApplication.xml you can configure every bean that you need such as

After that, edit your web.xml which is also under the WEB-INF. Add these line to call the applicationContext.xml

contextConfigLocation /WEB-INF/applicationContext.xml

org.springframework.web.context.ContextLoaderListener

Even thought it is basic one, but hopefully it helps you to configure your web application with spring framework

Cheers!