JAVA-2563: Upgrade Spring Boot version to 2.3.3.RELEASE (#9985)
* JAVA-2563: Upgrade Spring Boot version to 2.3.3.RELEASE * JAVA-2563: Downgrade spring-cloud-connectors-heroku to Spring Boot 2.2.6.RELEASE * JAVA-2563: Add joda-time version * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Use MongoClients factory instead of MongoClient directly * JAVA-2563: Downgrade spring-5-data-reactive to Spring Boot 2.2.6.RELEASE * JAVA-2563: Switch back to default bootstrap mode for JPA * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Switch from ServerHttpRequest to ServerWebExchange interface * JAVA-2563: Use OutputCaptureRule instead of OutputCapture * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Add spring-boot-starter-validation dependency * JAVA-2563: Fix Jackson dependency * JAVA-2563: Fix ManualEmbeddedMongoDbIntegrationTest * JAVA-2563: Replace validation-api with spring-boot-starter-validation * JAVA-2563: Fix usage of deprecated getErrorAttributes method * JAVA-2563: Downgrade spring-data-cassandra-reactive to Spring Boot 2.2.6.RELEASE * JAVA-2563: Set spring.datasource.generate-unique-name to false in spring-session-jdbc
This commit is contained in:
+4
-6
@@ -2,6 +2,8 @@
|
||||
package com.baeldung.reactive.errorhandling;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.web.error.ErrorAttributeOptions;
|
||||
import org.springframework.boot.web.reactive.error.DefaultErrorAttributes;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -13,13 +15,9 @@ public class GlobalErrorAttributes extends DefaultErrorAttributes{
|
||||
private HttpStatus status = HttpStatus.BAD_REQUEST;
|
||||
private String message = "please provide a name";
|
||||
|
||||
public GlobalErrorAttributes() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getErrorAttributes(ServerRequest request, boolean includeStackTrace) {
|
||||
Map<String, Object> map = super.getErrorAttributes(request, includeStackTrace);
|
||||
public Map<String, Object> getErrorAttributes(ServerRequest request, ErrorAttributeOptions options) {
|
||||
Map<String, Object> map = super.getErrorAttributes(request, options);
|
||||
map.put("status", getStatus());
|
||||
map.put("message", getMessage());
|
||||
return map;
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ package com.baeldung.reactive.errorhandling;
|
||||
import java.util.Map;
|
||||
import org.springframework.boot.autoconfigure.web.ResourceProperties;
|
||||
import org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler;
|
||||
import org.springframework.boot.web.error.ErrorAttributeOptions;
|
||||
import org.springframework.boot.web.reactive.error.ErrorAttributes;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.annotation.Order;
|
||||
@@ -37,7 +38,7 @@ public class GlobalErrorWebExceptionHandler extends AbstractErrorWebExceptionHan
|
||||
|
||||
private Mono<ServerResponse> renderErrorResponse(final ServerRequest request) {
|
||||
|
||||
final Map<String, Object> errorPropertiesMap = getErrorAttributes(request, false);
|
||||
final Map<String, Object> errorPropertiesMap = getErrorAttributes(request, ErrorAttributeOptions.defaults());
|
||||
|
||||
return ServerResponse.status(HttpStatus.BAD_REQUEST)
|
||||
.contentType(MediaType.APPLICATION_JSON_UTF8)
|
||||
|
||||
Reference in New Issue
Block a user