spring3.x upgrade to spring4.x encountered problems and solutions

Source: Internet
Author: User

The original project using SPRING3.X+JDK6, now upgrade to the SPRING4.X+JDK8, below on my upgrade process encountered problems to do a share.

The version of the spring that I upgraded to IS:

1 <Dependency>2    <groupId>Org.springframework</groupId>3    <Artifactid>Spring-context</Artifactid>4    <version>4.3.14.RELEASE</version>5 </Dependency>

1. If the SPRINGMVC is used, the dependencies associated with JSON need to be upgraded

1 <Dependency>2    <groupId>Com.alibaba</groupId>3    <Artifactid>Fastjson</Artifactid>4    <version>1.2.45</version>5 </Dependency>

Increase dependency:

1 <Dependency>2     <groupId>Com.fasterxml.jackson.core</groupId>3     <Artifactid>Jackson-annotations</Artifactid>4     <version>2.9.3</version>5 </Dependency>6 <Dependency>7     <groupId>Com.fasterxml.jackson.core</groupId>8     <Artifactid>Jackson-core</Artifactid>9     <version>2.9.3</version>Ten </Dependency> One <Dependency> A     <groupId>Com.fasterxml.jackson.core</groupId> -     <Artifactid>Jackson-databind</Artifactid> -     <version>2.9.3</version> the </Dependency>

Servlet.xml rewrite:

<id= "Mappingjacksonhttpmessageconverter"  class= " Org.springframework.http.converter.json.MappingJacksonHttpMessageConverter ">

Switch

<id= "Mappingjacksonhttpmessageconverter"  class= " Org.springframework.http.converter.json.MappingJackson2HttpMessageConverter ">

The change of 2.spring4.x writing

<local= "xxx"/>  changed to  <Bean = "XXX" /> that is, local  changes to  Bean

3. After spring 3.2.2, the (@Deprecated) queryForInt () in JdbcTemplate has been canceled, so it has to be changed to queryForObject ().

4. If JDK6 becomes JDK8 (spring4.x backwards-compatible to 6, 7 or 8 is recommended), then do not forget to change the compiler to the appropriate version, Eclipse has a variety of changes, I listed one (it is embarrassing, this way I only recently know):

In the Eclipse interface project, right-click properties-projectfacts-to modify the Java version, The usual compiler version is java1.6, change to java1.8 can, apply after automatically compiled, some people say to restart the effective, I seem to be instant, do not know is not my

Why the Eclipse version is high (Version:luna Service Release 2 (4.4.2))

5.spring upgrade to 4.x, ORM package inside Remove the support for Ibatis, so there are several ways to solve

A. Upgrade to MyBatis (the cost is sufficient to choose, after all, after the upgrade to MyBatis)

B.spring-orm package does not upgrade, still use spring3.x

C.spring-orm upgrade to 4.x, add the following dependencies

1 <Dependency>2     <groupId>Org.mybatis</groupId>3     <Artifactid>Mybatis-2-spring</Artifactid>4     <version>1.0.3</version>5 </Dependency> 

Additional questions are found during the subsequent testing process.

spring3.x upgrade to spring4.x encountered problems and solutions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.