1 Upgrade dependency package
1.1 Maven Project
1.1.1 Update spring dependency version
Open pom.xml and update all spring3.x version numbers to spring4.x. It is recommended to use attribute configuration, such as:
<properties> <spring.version>4.3.16.RELEASE</spring.version> </properties>
This requires only one upgrade, and the quote is as follows:
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version></dependency>...1.1.2 Upgrade quartz
quartz 1.x upgrade to quartz 2.x:
<dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>2.3.0</version></dependency>
Change org.springframework.scheduling.quartz.CronTriggerBean in the quartz configuration file org.springframework.scheduling.quartz.CronTriggerFactoryBean
1.1.3 Upgrading jackson
Jackson version upgraded to 2.9.4:
<jackson.version>2.9.4</jackson.version>
1.2 Non-Maven Projects
For projects that are not Maven, the process is more painful to update to Spring4.x, because the corresponding JAR package needs to be replaced manually.
Below is a JAR package that may be involved and needs to be replaced:
quartz Related
jackson related
Spring Related
2 Replace the queryForInt method of spring jdbc
The queryForInt method has been deprecated, please change to the queryForObject method:
queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
Call example: Copy the code code as follows: int count=namedParameterJdbcTemplate.queryForObject(sql,params, Integer.class);
3 SpringMVC returns JSON format
It turns out that in Spring3, the JSON format will be returned by default, but in Spring4, the XML format may be returned by default:
Response message format
If the response message format here becomes application/xml;charset=UTF-8, you can add produces = "application/json" to @RequestMapping in Controller to explicitly specify the return JSON format.
Example:
Copy the code as follows: @RequestMapping(value = "/login", method = RequestMethod.POST, produces = "application/json")
4 Update the xsd version number in the XML configuration file
Change the format as http://www.springframework.org/schema/xxx/spring-xxx-3.0.xsd to http://www.springframework.org/schema/xxx/spring-xxx-4.0.xsd , if any.
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.