JAVA-31190: Preparation for migrating spring-boot-modules to version 3. (#15834)

This commit is contained in:
Harry9656
2024-02-27 02:49:02 +01:00
committed by GitHub
parent 74da22b9c4
commit aefd833c3b
190 changed files with 1052 additions and 832 deletions
@@ -49,6 +49,11 @@
<artifactId>xstream</artifactId>
<version>${xstream.version}</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@@ -1,11 +1,11 @@
package com.baeldung.mime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Version;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Version;
import java.io.Serializable;
@Entity
@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;
@RestController
@RequestMapping(value = "/foos")
@@ -1,10 +1,8 @@
package com.baeldung.students;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@@ -16,14 +14,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import com.baeldung.students.StudentService;
@RestController
@RequestMapping("/students")
public class StudentController {
@Autowired
private StudentService service;
private final StudentService service;
public StudentController(StudentService service) {
this.service = service;
}
@GetMapping("/")
public List<Student> read() {
@@ -31,7 +30,7 @@ public class StudentController {
}
@GetMapping("/{id}")
public ResponseEntity<Student> read(@PathVariable("id") Long id) {
public ResponseEntity<Student> read(@PathVariable(name = "id") Long id) {
Student foundStudent = service.read(id);
if (foundStudent == null) {
return ResponseEntity.notFound().build();
@@ -41,7 +40,7 @@ public class StudentController {
}
@PostMapping("/")
public ResponseEntity<Student> create(@RequestBody Student student) throws URISyntaxException {
public ResponseEntity<Student> create(@RequestBody Student student) {
Student createdStudent = service.create(student);
URI uri = ServletUriComponentsBuilder.fromCurrentRequest()
@@ -55,7 +54,7 @@ public class StudentController {
}
@PutMapping("/{id}")
public ResponseEntity<Student> update(@RequestBody Student student, @PathVariable Long id) {
public ResponseEntity<Student> update(@RequestBody Student student, @PathVariable(name = "id") Long id) {
Student updatedStudent = service.update(id, student);
if (updatedStudent == null) {
return ResponseEntity.notFound().build();
@@ -65,10 +64,9 @@ public class StudentController {
}
@DeleteMapping("/{id}")
public ResponseEntity<Object> deleteStudent(@PathVariable Long id) {
public ResponseEntity<Object> deleteStudent(@PathVariable(name = "id") Long id) {
service.delete(id);
return ResponseEntity.noContent().build();
}
}
@@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;