How to upgrade ALL the spring dependency?

后端 未结 4 1724
情话喂你
情话喂你 2021-02-06 19:54

I have a spring-webmvc based web application. It used the org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer which is not

相关标签:
4条回答
  • 2021-02-06 20:06

    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.

    0 讨论(0)
  • 2021-02-06 20:21

    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

    0 讨论(0)
  • 2021-02-06 20:27

    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>
    
    0 讨论(0)
  • 2021-02-06 20:30

    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

    0 讨论(0)
提交回复
热议问题