diff --git a/spring-boot-modules/spring-boot/README.MD b/spring-boot-modules/spring-boot/README.MD index 83cc26fdec..16f20d889c 100644 --- a/spring-boot-modules/spring-boot/README.MD +++ b/spring-boot-modules/spring-boot/README.MD @@ -20,7 +20,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Getting Started with GraphQL and Spring Boot](https://www.baeldung.com/spring-graphql) - [Guide to Spring Type Conversions](https://www.baeldung.com/spring-type-conversions) - [An Introduction to Kong](https://www.baeldung.com/kong) -- [Spring Boot: Customize Whitelabel Error Page](https://www.baeldung.com/spring-boot-custom-error-page) - [Spring Boot: Configuring a Main Class](https://www.baeldung.com/spring-boot-main-class) - [A Quick Intro to the SpringBootServletInitializer](https://www.baeldung.com/spring-boot-servlet-initializer) - [How to Define a Spring Boot Filter?](https://www.baeldung.com/spring-boot-add-filter) diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/ErrorHandlingApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/ErrorHandlingApplication.java deleted file mode 100644 index 5dd55ef077..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/ErrorHandlingApplication.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.errorhandling; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = "com.baeldung.errorhandling") -public class ErrorHandlingApplication { - - public static void main(String [] args) { - System.setProperty("spring.profiles.active", "errorhandling"); - SpringApplication.run(ErrorHandlingApplication.class, args); - } -} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/IndexController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/IndexController.java deleted file mode 100644 index 1a8761e96b..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/IndexController.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.baeldung.errorhandling.controllers; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; - -@Controller -public class IndexController { - - @GetMapping(value = {"/", ""}) - public String index() { - return "index"; - } - - @GetMapping(value = {"/server_error"}) - public String triggerServerError() { - "ser".charAt(30); - return "index"; - } - - @PostMapping(value = {"/general_error"}) - public String triggerGeneralError() { - return "index"; - } - -} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java deleted file mode 100644 index e002ac045d..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.baeldung.errorhandling.controllers; - -import org.springframework.boot.web.servlet.error.ErrorController; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -import javax.servlet.RequestDispatcher; -import javax.servlet.http.HttpServletRequest; - -@Controller -public class MyErrorController implements ErrorController { - - public MyErrorController() {} - - @GetMapping(value = "/error") - public String handleError(HttpServletRequest request) { - - Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); - - if (status != null) { - - Integer statusCode = Integer.valueOf(status.toString()); - - if(statusCode == HttpStatus.NOT_FOUND.value()) { - return "error-404"; - } - else if(statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value()) { - return "error-500"; - } - } - return "error"; - } - - @Override - public String getErrorPath() { - return "/error"; - } - -} diff --git a/spring-boot-modules/spring-boot/src/main/resources/application-errorhandling.properties b/spring-boot-modules/spring-boot/src/main/resources/application-errorhandling.properties index 6ffcfbaf52..270e86d443 100644 --- a/spring-boot-modules/spring-boot/src/main/resources/application-errorhandling.properties +++ b/spring-boot-modules/spring-boot/src/main/resources/application-errorhandling.properties @@ -1,10 +1,4 @@ #server server.port=9000 server.servlet-path=/ -server.context-path=/ -#server.error.whitelabel.enabled=false - -#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration - -#for Spring Boot 2.0+ -#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration \ No newline at end of file +server.context-path=/ \ No newline at end of file diff --git a/spring-boot-modules/spring-boot/src/main/resources/templates/error-404.html b/spring-boot-modules/spring-boot/src/main/resources/templates/error-404.html deleted file mode 100644 index cf68032596..0000000000 --- a/spring-boot-modules/spring-boot/src/main/resources/templates/error-404.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - -
-
-

Sorry, we couldn't find the page you were looking for.

-

Go Home

-
- - \ No newline at end of file diff --git a/spring-boot-modules/spring-boot/src/main/resources/templates/error-500.html b/spring-boot-modules/spring-boot/src/main/resources/templates/error-500.html deleted file mode 100644 index 5ddf458229..0000000000 --- a/spring-boot-modules/spring-boot/src/main/resources/templates/error-500.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - -
-
-

Sorry, something went wrong!

- -

We're fixing it.

-

Go Home

-
- - \ No newline at end of file