JAVA-31602 :- Upgrade spring-boot-mvc-2, spring-boot-mvc-5 to boot 3.2.2 (#16188)

* JAVA-31602 :- Upgrade spring-boot-mvc-2, spring-boot-mvc-5 to boot 3.2.2

* JAVA-31602 :- Upgrade spring-boot-mvc-2, spring-boot-mvc-5 to boot 3.2.2

* Revert parent pom to restrict build

* JAVA-31602 :- Upgrade spring-boot-mvc-2, spring-boot-mvc-5 to boot 3.2.2

* Fix version error

* JAVA-31602 :- Upgrade spring-boot-mvc-2, spring-boot-mvc-5 to boot 3.2.2

* Fix version error

* JAVA-31602 :- Upgrade spring-boot-mvc-2, spring-boot-mvc-5 to boot 3.2.2

* Fix version error

* Fix version error

* Enable in Parent POM

* Fix haslength approach

---------

Co-authored-by: Amit Pandey <amitpandey@cloud.upwork.com>
This commit is contained in:
Amit Pandey
2024-03-23 17:19:34 +05:30
committed by GitHub
parent 9cc307e108
commit 8bd2ca6893
10 changed files with 34 additions and 26 deletions
@@ -53,6 +53,7 @@
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
<version>${rest-assured-version}</version>
</dependency>
</dependencies>
@@ -80,7 +81,11 @@
<properties>
<spring.fox.version>3.0.0</spring.fox.version>
<start-class>com.baeldung.springbootmvc.SpringBootMvcFnApplication</start-class>
<maven.compiler.release>17</maven.compiler.release>
<xstream.version>1.4.11.1</xstream.version>
<rest-assured-version>5.4.0</rest-assured-version>
<spring-boot.version>3.2.2</spring-boot.version>
<junit-jupiter.version>5.10.2</junit-jupiter.version>
</properties>
</project>
@@ -2,12 +2,9 @@ package com.baeldung.mime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
@@ -4,8 +4,9 @@ import static org.springframework.web.servlet.function.RouterFunctions.route;
import static org.springframework.web.servlet.function.ServerResponse.ok;
import static org.springframework.web.servlet.function.ServerResponse.status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.baeldung.springbootmvc.SpringBootMvcFnApplication.Error;
import com.baeldung.springbootmvc.model.Product;
import com.baeldung.springbootmvc.svc.ProductService;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.function.EntityResponse;
@@ -14,10 +15,6 @@ import org.springframework.web.servlet.function.RouterFunction;
import org.springframework.web.servlet.function.ServerRequest;
import org.springframework.web.servlet.function.ServerResponse;
import com.baeldung.springbootmvc.SpringBootMvcFnApplication.Error;
import com.baeldung.springbootmvc.model.Product;
import com.baeldung.springbootmvc.svc.ProductService;
@Component
public class ProductController {
@@ -27,10 +24,8 @@ public class ProductController {
}
public RouterFunction<ServerResponse> productSearch(ProductService ps) {
return route().nest(RequestPredicates.path("/product"), builder -> {
builder.GET("/name/{name}", req -> ok().body(ps.findByName(req.pathVariable("name"))))
.GET("/id/{id}", req -> ok().body(ps.findById(Integer.parseInt(req.pathVariable("id")))));
})
return route().nest(RequestPredicates.path("/product"), builder -> builder.GET("/name/{name}", req -> ok().body(ps.findByName(req.pathVariable("name"))))
.GET("/id/{id}", req -> ok().body(ps.findById(Integer.parseInt(req.pathVariable("id"))))))
.onError(ProductService.ItemNotFoundException.class, (e, req) -> EntityResponse.fromObject(new Error(e.getMessage()))
.status(HttpStatus.NOT_FOUND)
.build())
@@ -38,7 +38,7 @@ public class ProductService {
}
public Product save(Product product) {
if (StringUtils.isEmpty(product.getName()) || product.getPrice() == 0.0) {
if (!StringUtils.hasLength(product.getName()) || product.getPrice() == 0.0) {
throw new IllegalArgumentException();
}
int newId = products.stream()
@@ -19,7 +19,7 @@ public class StudentService {
new Student(2, "Sebastian","Bach"),
new Student(3, "Pablo","Picasso"),
}).stream()
.collect(Collectors.toConcurrentMap(s -> s.getId(), Function.identity()));
.collect(Collectors.toConcurrentMap(Student::getId, Function.identity()));
// DB id sequence mock
private AtomicLong sequence = new AtomicLong(3);