From 53b3bca14dd294eada0534ae1782d4078509ba2e Mon Sep 17 00:00:00 2001 From: sam-gardner <53271849+sam-gardner@users.noreply.github.com> Date: Thu, 21 Mar 2024 19:53:37 +0000 Subject: [PATCH] JAVA-32062 Upgrade spring-ressttemplate-1 to spring boot 3 (#16164) --- spring-web-modules/spring-resttemplate-1/pom.xml | 8 ++++++-- .../resttemplate/lists/client/EmployeeClient.java | 10 +++++----- .../resttemplate/web/controller/PersonAPI.java | 2 +- .../resttemplate/postjson/PersonAPILiveTest.java | 4 ++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/spring-web-modules/spring-resttemplate-1/pom.xml b/spring-web-modules/spring-resttemplate-1/pom.xml index 209c941ede..5900e816ed 100644 --- a/spring-web-modules/spring-resttemplate-1/pom.xml +++ b/spring-web-modules/spring-resttemplate-1/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-boot-2 + parent-boot-3 0.0.1-SNAPSHOT - ../../parent-boot-2 + ../../parent-boot-3 @@ -27,4 +27,8 @@ + + com.baeldung.resttemplate.RestTemplateApplication + + \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate-1/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java b/spring-web-modules/spring-resttemplate-1/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java index 7fa0d55690..aa9ad9699f 100644 --- a/spring-web-modules/spring-resttemplate-1/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java +++ b/spring-web-modules/spring-resttemplate-1/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java @@ -46,7 +46,7 @@ public class EmployeeClient { ResponseEntity response = restTemplate.getForEntity( - "http://localhost:8082/spring-rest/employees/", + "http://localhost:8080/spring-rest/employees/", Employee[].class); Employee[] employees = response.getBody(); @@ -64,7 +64,7 @@ public class EmployeeClient { ResponseEntity> response = restTemplate.exchange( - "http://localhost:8082/spring-rest/employees/", + "http://localhost:8080/spring-rest/employees/", HttpMethod.GET, null, new ParameterizedTypeReference>() { @@ -83,7 +83,7 @@ public class EmployeeClient { EmployeeList response = restTemplate.getForObject( - "http://localhost:8082/spring-rest/employees/v2", + "http://localhost:8080/spring-rest/employees/v2", EmployeeList.class); List employees = response.getEmployees(); @@ -101,7 +101,7 @@ public class EmployeeClient { newEmployees.add(new Employee(4, "CEO")); restTemplate.postForObject( - "http://localhost:8082/spring-rest/employees/", + "http://localhost:8080/spring-rest/employees/", newEmployees, ResponseEntity.class); } @@ -114,7 +114,7 @@ public class EmployeeClient { newEmployees.add(new Employee(4, "CEO")); restTemplate.postForObject( - "http://localhost:8082/spring-rest/employees/v2/", + "http://localhost:8080/spring-rest/employees/v2", new EmployeeList(newEmployees), ResponseEntity.class); } diff --git a/spring-web-modules/spring-resttemplate-1/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java b/spring-web-modules/spring-resttemplate-1/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java index b3131cc00c..8c74aa9bad 100644 --- a/spring-web-modules/spring-resttemplate-1/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java +++ b/spring-web-modules/spring-resttemplate-1/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java @@ -1,6 +1,6 @@ package com.baeldung.resttemplate.web.controller; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import com.baeldung.resttemplate.web.service.PersonService; import com.baeldung.resttemplate.web.dto.Person; diff --git a/spring-web-modules/spring-resttemplate-1/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java b/spring-web-modules/spring-resttemplate-1/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java index f1861ede92..73a408b67f 100644 --- a/spring-web-modules/spring-resttemplate-1/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java +++ b/spring-web-modules/spring-resttemplate-1/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java @@ -41,8 +41,8 @@ public class PersonAPILiveTest { @BeforeClass public static void runBeforeAllTestMethods() throws JSONException { - createPersonUrl = "http://localhost:8082/spring-rest/createPerson"; - updatePersonUrl = "http://localhost:8082/spring-rest/updatePerson"; + createPersonUrl = "http://localhost:8080/spring-rest/createPerson"; + updatePersonUrl = "http://localhost:8080/spring-rest/updatePerson"; restTemplate = new RestTemplate();