I upgraded my Spring Boot projects on Github from the 1.5.x version to the newest 2.0 over the weekend. These are my experiences:
immontilla/file-uploading-web-app
- webjars-locator dependency missing
I had to change the dependency org.webjar.webjars-locator to org.webjar.webjars-locator-core. I found out how to solve it in this article: Spring-Boot-2.0-Migration-Guide#webjars-locator.
- Spring 5 - MockMvcRequestBuilders.fileUpload deprecation
In Spring 5, MockMvcRequestBuilders.fileUpload has been deprecated in favour of MockMvcRequestBuilders.multipart. Read the details here: Deprecated List (Spring Framework 5.0.3.RELEASE API).
I had to change this:
MockMultipartFile csvFile = new MockMultipartFile("file", "test", "text/csv", "a,b,c,d,e,f".getBytes());
this.mvc.perform(fileUpload("/upload").file(csvFile)).andExpect(status().isBadRequest()).andExpect(jsonPath("$.validFileExtension").value("false"));
to:
ResultMatcher badRequest = MockMvcResultMatchers.status().isBadRequest();
MockMultipartFile csvFile = new MockMultipartFile("file", "test", "text/csv", "a,b,c,d,e,f".getBytes());
MockHttpServletRequestBuilder uploadRequest = MockMvcRequestBuilders.multipart("/upload").file(csvFile);
mockMVC.perform(uploadRequest).andExpect(badRequest).andExpect(jsonPath("$.validFileExtension").value("false"));
Honouring "Uncle Bob", I tweaked a little the test code readability as well.
- Upgraded project dependencies
These changes are not related to the Spring Boot version upgrade. Its only goal is to keep the project's dependencies up-to-date.
org.apache.tika.tika-core was upgraded from 1.16 to 1.17
com.google.guava.guava has been split in two versions jre and android. Formerly was just 23, now is 24.0-jre
org.webjars.bootstrap is not an alpha version anymore. I upgraded it from 4.0.0-alpha.6-1 to 4.0.0-2 version
org.webjars.jquery was upgraded from 3.2.1 to 3.3.1-1
org.webjars.tether was upgraded from 1.4.0 to 1.4.3
immontilla/spring-boot-https-server
- Plugin io.spring.dependency-management
I had to add the io.spring.dependency-management plugin to the build.gradle file. Without it, the building process will fail.
- ErrorAttributes and ErrorController classes
In Spring Boot 2.0, the ErrorAttributes and ErrorController classes has been packaged in org.springframework.boot.autoconfigure.web. In Spring Boot 1.5.x, was packaged in org.springframework.boot.web.servlet.error.
- Upgraded project dependencies
org.webjars:webjars-locator:0.32-1 was changed to org.webjars.webjars-locator-core.
org.webjars.bootstrap was upgraded from 4.0.0-alpha.6-1 to 4.0.0-2 version.
com.google.code.gson was upgraded from 2.8.1 to 2.8.2 version.
immontilla/wedeploy-norrisws
This project required the same fixes than immontilla/spring-boot-https-server except any dependency upgrade.
Final thoughts
I recommend to apply the Spring Boot upgrade sooner than later. At least in my case, it was a really straightforward process.