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

View File

@ -46,7 +46,7 @@ public class EmployeeClient {
ResponseEntity<Employee[]> 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<List<Employee>> response =
restTemplate.exchange(
"http://localhost:8082/spring-rest/employees/",
"http://localhost:8080/spring-rest/employees/",
HttpMethod.GET,
null,
new ParameterizedTypeReference<List<Employee>>() {
@ -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<Employee> 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);
}

View File

@ -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;

View File

@ -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();