Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Upgrading to Spring 3.1

DZone's Guide to

Upgrading to Spring 3.1

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

A few days ago I thought that it was about time to upgrade my sample code to Spring 3.1, after all it’s been around for a respectable amount of time and has a couple of bug fix releases.

Upgrading to Spring 3.1 is very simple of upgrading your Maven version number and rebuilding, something like this:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>3.1.2.RELEASE</version>
</dependency>

After recompiling you’ll probably find a whole bunch of newly deprecated classes such as XmlBeanFactory, which has been deprecated in favour of DefaultListableBeanFactory so,
    Resource resource = new ClassPathResource("example2.xml");
    return new XmlBeanFactory(resource);

becomes

    Resource resource = new ClassPathResource("example2.xml");

    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
    reader.loadBeanDefinitions(resource);

For a full list of deprecated classes http://static.springsource.org/spring/docs/3.1.x/javadoc-api/deprecated-list.html

The next thing to do is option, but a good idea is to change your Spring XML headers from 3.0 to 3.1 so that the XML schema’s referenced end in -3.1.xsd. For example:

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

becomes

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd

The easiest way of doing this is to use eclipse’s global replace to replace to change -3.0.xsd with -3.1.xsd, but have a quick check first before your do this...

The reason for updating your schema’s is to take advantage of Spring’s new features, but more on that later...

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.

Topics:

Published at DZone with permission of Roger Hughes, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}