JAVA-32062 Upgrade spring-ressttemplate-1 to spring boot 3 (#16164)

This commit is contained in:
sam-gardner 2024-03-21 19:53:37 +00:00 committed by GitHub
parent 317496fa87
commit 53b3bca14d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 10 deletions

View File

@ -10,9 +10,9 @@
<parent> <parent>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>parent-boot-2</artifactId> <artifactId>parent-boot-3</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-boot-2</relativePath> <relativePath>../../parent-boot-3</relativePath>
</parent> </parent>
<dependencies> <dependencies>
@ -27,4 +27,8 @@
</dependency> </dependency>
</dependencies> </dependencies>
<properties>
<start-class>com.baeldung.resttemplate.RestTemplateApplication</start-class>
</properties>
</project> </project>

View File

@ -46,7 +46,7 @@ public class EmployeeClient {
ResponseEntity<Employee[]> response = ResponseEntity<Employee[]> response =
restTemplate.getForEntity( restTemplate.getForEntity(
"http://localhost:8082/spring-rest/employees/", "http://localhost:8080/spring-rest/employees/",
Employee[].class); Employee[].class);
Employee[] employees = response.getBody(); Employee[] employees = response.getBody();
@ -64,7 +64,7 @@ public class EmployeeClient {
ResponseEntity<List<Employee>> response = ResponseEntity<List<Employee>> response =
restTemplate.exchange( restTemplate.exchange(
"http://localhost:8082/spring-rest/employees/", "http://localhost:8080/spring-rest/employees/",
HttpMethod.GET, HttpMethod.GET,
null, null,
new ParameterizedTypeReference<List<Employee>>() { new ParameterizedTypeReference<List<Employee>>() {
@ -83,7 +83,7 @@ public class EmployeeClient {
EmployeeList response = EmployeeList response =
restTemplate.getForObject( restTemplate.getForObject(
"http://localhost:8082/spring-rest/employees/v2", "http://localhost:8080/spring-rest/employees/v2",
EmployeeList.class); EmployeeList.class);
List<Employee> employees = response.getEmployees(); List<Employee> employees = response.getEmployees();
@ -101,7 +101,7 @@ public class EmployeeClient {
newEmployees.add(new Employee(4, "CEO")); newEmployees.add(new Employee(4, "CEO"));
restTemplate.postForObject( restTemplate.postForObject(
"http://localhost:8082/spring-rest/employees/", "http://localhost:8080/spring-rest/employees/",
newEmployees, newEmployees,
ResponseEntity.class); ResponseEntity.class);
} }
@ -114,7 +114,7 @@ public class EmployeeClient {
newEmployees.add(new Employee(4, "CEO")); newEmployees.add(new Employee(4, "CEO"));
restTemplate.postForObject( restTemplate.postForObject(
"http://localhost:8082/spring-rest/employees/v2/", "http://localhost:8080/spring-rest/employees/v2",
new EmployeeList(newEmployees), new EmployeeList(newEmployees),
ResponseEntity.class); ResponseEntity.class);
} }

View File

@ -1,6 +1,6 @@
package com.baeldung.resttemplate.web.controller; 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.service.PersonService;
import com.baeldung.resttemplate.web.dto.Person; import com.baeldung.resttemplate.web.dto.Person;

View File

@ -41,8 +41,8 @@ public class PersonAPILiveTest {
@BeforeClass @BeforeClass
public static void runBeforeAllTestMethods() throws JSONException { public static void runBeforeAllTestMethods() throws JSONException {
createPersonUrl = "http://localhost:8082/spring-rest/createPerson"; createPersonUrl = "http://localhost:8080/spring-rest/createPerson";
updatePersonUrl = "http://localhost:8082/spring-rest/updatePerson"; updatePersonUrl = "http://localhost:8080/spring-rest/updatePerson";
restTemplate = new RestTemplate(); restTemplate = new RestTemplate();