smwikipedia
smwikipedia

Reputation: 64433

How to upgrade ALL the spring dependency?

I have a spring-webmvc based web application. It used the org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer which is not supported by the spring version used in my project.

My project's spring dependency look like this:

enter image description here

I want to upgrade all spring dependency from 3.1.1 to 4.1.2. How to do that?

Upvotes: 3

Views: 27142

Answers (4)

Ummer Iqbal
Ummer Iqbal

Reputation: 136

If you using maven build tool,so it's very simple to upgrade spring 3 to spring 4 you just open pom.xml file in the properties xml tag just change the version 3.x.x to 4 something. e.g:

<org.springframework-version>3.0.2.RELEASE</org.springframework-version>

to

<org.springframework-version>4.0.2.RELEASE</org.springframework-version>

Upvotes: 1

J2B
J2B

Reputation: 1753

Since you are using Maven, your pom-dependencies will probably look like

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

You could replace "3.1.1.RELEASE" with ${spring-version}, and add the following to your pom-file

<properties>
  <spring-version>4.1.2</spring-version>
</properties>

It will make it easier to change version for all your spring dependencies

Upvotes: 2

user3145373 ツ
user3145373 ツ

Reputation: 8156

you can update dependency like this globally :

<properties>
        <spring.version>4.1.2.RELEASE</spring.version>
</properties>

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>${spring.version}</version>
</dependency>

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${spring.version}</version>
</dependency>

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${spring.version}</version>
</dependency>

using this global dependency version management, you can avoid some version compatibility exception.

Upvotes: 3

Master Slave
Master Slave

Reputation: 28569

You should move from a hardcoded version of a spring version inside a pom.xml to a property, e.g.

inside your properties

 <springframework.version>4.0.2.RELEASE</springframework.version>

inside your dependencies

<!-- spring -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-expression</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${springframework.version}</version>
</dependency>
<!-- spring security -->
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
    <version>${springframework.security.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>${springframework.security.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-web</artifactId>
    <version>${springframework.security.version}</version>
</dependency>

with this setup its easy to migrate the versions, the listed deps are just copy/paste, don't take it for granted, use what you need

Upvotes: 5

Related Questions