diff --git a/spring-boot-modules/spring-boot-mvc/README.md b/spring-boot-modules/spring-boot-mvc/README.md index 2e67c42ede..41b98063a6 100644 --- a/spring-boot-modules/spring-boot-mvc/README.md +++ b/spring-boot-modules/spring-boot-mvc/README.md @@ -4,7 +4,6 @@ This module contains articles about Spring Web MVC in Spring Boot projects. ### Relevant Articles: -- [Guide to the Favicon in Spring Boot](https://www.baeldung.com/spring-boot-favicon) - [Custom Validation MessageSource in Spring Boot](https://www.baeldung.com/spring-custom-validation-message-source) - [Display RSS Feed with Spring MVC](https://www.baeldung.com/spring-mvc-rss-feed) - [A Controller, Service and DAO Example with Spring Boot and JSF](https://www.baeldung.com/jsf-spring-boot-controller-service-dao) diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/config/FaviconConfiguration.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/config/FaviconConfiguration.java deleted file mode 100644 index 9a1f47b5cb..0000000000 --- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/config/FaviconConfiguration.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.baeldung.springbootmvc.config; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; -import org.springframework.web.servlet.resource.ResourceHttpRequestHandler; - -@Configuration -public class FaviconConfiguration { - @Bean - public SimpleUrlHandlerMapping myFaviconHandlerMapping() { - SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); - mapping.setOrder(Integer.MIN_VALUE); - mapping.setUrlMap(Collections.singletonMap("/favicon.ico", faviconRequestHandler())); - return mapping; - } - - @Bean - protected ResourceHttpRequestHandler faviconRequestHandler() { - ResourceHttpRequestHandler requestHandler = new ResourceHttpRequestHandler(); - ClassPathResource classPathResource = new ClassPathResource("com/baeldung/images"); - List locations = Arrays.asList(classPathResource); - requestHandler.setLocations(locations); - return requestHandler; - } - - // @Controller - static class FaviconController { - - @RequestMapping(value = "favicon.ico", method = RequestMethod.GET) - @ResponseBody - void favicon() { - } - } -} diff --git a/spring-boot-modules/spring-boot-mvc/src/main/resources/com/baeldung/images/favicon.ico b/spring-boot-modules/spring-boot-mvc/src/main/resources/com/baeldung/images/favicon.ico deleted file mode 100644 index 64105ac11c..0000000000 Binary files a/spring-boot-modules/spring-boot-mvc/src/main/resources/com/baeldung/images/favicon.ico and /dev/null differ diff --git a/spring-boot-modules/spring-boot-mvc/src/main/resources/favicon.ico b/spring-boot-modules/spring-boot-mvc/src/main/resources/favicon.ico deleted file mode 100644 index 64105ac11c..0000000000 Binary files a/spring-boot-modules/spring-boot-mvc/src/main/resources/favicon.ico and /dev/null differ diff --git a/spring-boot-modules/spring-boot-mvc/src/main/resources/static/favicon.ico b/spring-boot-modules/spring-boot-mvc/src/main/resources/static/favicon.ico deleted file mode 100644 index 64105ac11c..0000000000 Binary files a/spring-boot-modules/spring-boot-mvc/src/main/resources/static/favicon.ico and /dev/null differ diff --git a/spring-boot-modules/spring-boot-runtime/README.md b/spring-boot-modules/spring-boot-runtime/README.md index a544faf830..62727ecc76 100644 --- a/spring-boot-modules/spring-boot-runtime/README.md +++ b/spring-boot-modules/spring-boot-runtime/README.md @@ -8,7 +8,6 @@ This module contains articles about administering a Spring Boot runtime - [Logging HTTP Requests with Spring Boot Actuator HTTP Tracing](https://www.baeldung.com/spring-boot-actuator-http) - [How to Disable Console Logging in Spring Boot](https://www.baeldung.com/spring-boot-disable-console-logging) - [Spring Boot Embedded Tomcat Logs](https://www.baeldung.com/spring-boot-embedded-tomcat-logs) - - [How to Change the Default Port in Spring Boot](https://www.baeldung.com/spring-boot-change-port) - [Project Configuration with Spring](https://www.baeldung.com/project-configuration-with-spring) - [CORS with Spring](https://www.baeldung.com/spring-cors) - [Spring – Log Incoming Requests](https://www.baeldung.com/spring-http-logging) \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/changeport/CustomApplication.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/changeport/CustomApplication.java deleted file mode 100644 index 3fce0f1289..0000000000 --- a/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/changeport/CustomApplication.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.changeport; - -import java.util.Collections; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class CustomApplication { - - public static void main(String[] args) { - SpringApplication app = new SpringApplication(CustomApplication.class); - app.setDefaultProperties(Collections.singletonMap("server.port", "8083")); - app.run(args); - } - -} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/changeport/ServerPortCustomizer.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/changeport/ServerPortCustomizer.java deleted file mode 100644 index f3610aeac6..0000000000 --- a/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/changeport/ServerPortCustomizer.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.changeport; - -import org.springframework.boot.web.server.ConfigurableWebServerFactory; -import org.springframework.boot.web.server.WebServerFactoryCustomizer; -import org.springframework.stereotype.Component; - -//@Component -public class ServerPortCustomizer implements WebServerFactoryCustomizer { - - @Override - public void customize(ConfigurableWebServerFactory factory) { - factory.setPort(8086); - } - -} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot/README.MD b/spring-boot-modules/spring-boot/README.MD index 217d9e90b2..b15ab7dbe5 100644 --- a/spring-boot-modules/spring-boot/README.MD +++ b/spring-boot-modules/spring-boot/README.MD @@ -11,9 +11,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [The @ServletComponentScan Annotation in Spring Boot](https://www.baeldung.com/spring-servletcomponentscan) - [How to Register a Servlet in Java](https://www.baeldung.com/register-servlet) - [Guide to Spring WebUtils and ServletRequestUtils](https://www.baeldung.com/spring-webutils-servletrequestutils) -- [Using Custom Banners in Spring Boot](https://www.baeldung.com/spring-boot-custom-banners) - [Guide to Internationalization in Spring Boot](https://www.baeldung.com/spring-boot-internationalization) -- [Create a Custom FailureAnalyzer with Spring Boot](https://www.baeldung.com/spring-boot-failure-analyzer) - [Dynamic DTO Validation Config Retrieved from the Database](https://www.baeldung.com/spring-dynamic-dto-validation) - [Custom Information in Spring Boot Info Endpoint](https://www.baeldung.com/spring-boot-info-actuator-custom) - [Testing in Spring Boot](https://www.baeldung.com/spring-boot-testing) @@ -22,11 +20,8 @@ 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) -- [Spring Boot Exit Codes](https://www.baeldung.com/spring-boot-exit-codes) - [Guide to the Favicon in Spring Boot](https://www.baeldung.com/spring-boot-favicon) - [Spring Shutdown Callbacks](https://www.baeldung.com/spring-shutdown-callbacks) - [Container Configuration in Spring Boot 2](https://www.baeldung.com/embeddedservletcontainercustomizer-configurableembeddedservletcontainer-spring-boot) diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/FilterConfig.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/FilterConfig.java deleted file mode 100644 index aa794182de..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/FilterConfig.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.bootcustomfilters; - -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import com.baeldung.bootcustomfilters.filters.RequestResponseLoggingFilter; - -@Configuration -public class FilterConfig { - - // uncomment this and comment the @Component in the filter class definition to register only for a url pattern - // @Bean - public FilterRegistrationBean loggingFilter() { - FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); - - registrationBean.setFilter(new RequestResponseLoggingFilter()); - - registrationBean.addUrlPatterns("/users/*"); - - return registrationBean; - - } - -} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/SpringBootFiltersApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/SpringBootFiltersApplication.java deleted file mode 100644 index c4653932c0..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/SpringBootFiltersApplication.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.bootcustomfilters; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Boot application - * @author hemant - * - */ -@SpringBootApplication -public class SpringBootFiltersApplication { - - public static void main(String[] args) { - SpringApplication.run(SpringBootFiltersApplication.class, args); - } -} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/controller/UserController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/controller/UserController.java deleted file mode 100644 index 97165f2cf3..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/controller/UserController.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.baeldung.bootcustomfilters.controller; - -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.baeldung.bootcustomfilters.model.User; - -/** - * Rest controller for User - * @author hemant - * - */ -@RestController -@RequestMapping("/users") -public class UserController { - - private static final Logger LOG = LoggerFactory.getLogger(UserController.class); - - @GetMapping("") - public List getAllUsers() { - LOG.info("Fetching all the users"); - return Arrays.asList( - new User(UUID.randomUUID().toString(), "User1", "user1@test.com"), - new User(UUID.randomUUID().toString(), "User1", "user1@test.com"), - new User(UUID.randomUUID().toString(), "User1", "user1@test.com")); - } - -} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/RequestResponseLoggingFilter.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/RequestResponseLoggingFilter.java deleted file mode 100644 index e42ea7d2dd..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/RequestResponseLoggingFilter.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.baeldung.bootcustomfilters.filters; - -import java.io.IOException; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * A servlet filter to log request and response - * The logging implementation is pretty native and for demonstration only - * @author hemant - * - */ -@Component -@Order(2) -public class RequestResponseLoggingFilter implements Filter { - - private final static Logger LOG = LoggerFactory.getLogger(RequestResponseLoggingFilter.class); - - @Override - public void init(final FilterConfig filterConfig) throws ServletException { - LOG.info("Initializing filter :{}", this); - } - - @Override - public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) - throws IOException, ServletException { - HttpServletRequest req = (HttpServletRequest) request; - HttpServletResponse res = (HttpServletResponse) response; - LOG.info("Logging Request {} : {}", req.getMethod(), req.getRequestURI()); - chain.doFilter(request, response); - LOG.info("Logging Response :{}", res.getContentType()); - } - - @Override - public void destroy() { - LOG.warn("Destructing filter :{}", this); - } -} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/TransactionFilter.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/TransactionFilter.java deleted file mode 100644 index d92b723e73..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/TransactionFilter.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.baeldung.bootcustomfilters.filters; - -import java.io.IOException; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * A filter to create transaction before and commit it once request completes - * The current implemenatation is just for demo - * @author hemant - * - */ -@Component -@Order(1) -public class TransactionFilter implements Filter { - - private final static Logger LOG = LoggerFactory.getLogger(TransactionFilter.class); - - @Override - public void init(final FilterConfig filterConfig) throws ServletException { - LOG.info("Initializing filter :{}", this); - } - - @Override - public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { - HttpServletRequest req = (HttpServletRequest) request; - LOG.info("Starting Transaction for req :{}", req.getRequestURI()); - chain.doFilter(request, response); - LOG.info("Committing Transaction for req :{}", req.getRequestURI()); - } - - @Override - public void destroy() { - LOG.warn("Destructing filter :{}", this); - } -} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/model/User.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/model/User.java deleted file mode 100644 index ab8e6c8206..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/model/User.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.baeldung.bootcustomfilters.model; - -/** - * User model - * @author hemant - * - */ -public class User { - - private String id; - private String name; - private String email; - - public User(String id, String name, String email) { - super(); - this.id = id; - this.name = name; - this.email = email; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - -} 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/java/com/baeldung/failureanalyzer/FailureAnalyzerApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/FailureAnalyzerApplication.java deleted file mode 100644 index 7bd5c36786..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/FailureAnalyzerApplication.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung.failureanalyzer; - -import javax.annotation.security.RolesAllowed; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class FailureAnalyzerApplication { - @RolesAllowed("*") - public static void main(String[] args) { - SpringApplication.run(FailureAnalyzerApplication.class, args); - } -} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyBeanNotOfRequiredTypeFailureAnalyzer.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyBeanNotOfRequiredTypeFailureAnalyzer.java deleted file mode 100644 index 3949908083..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyBeanNotOfRequiredTypeFailureAnalyzer.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.failureanalyzer; - -import org.springframework.beans.factory.BeanNotOfRequiredTypeException; -import org.springframework.boot.diagnostics.AbstractFailureAnalyzer; -import org.springframework.boot.diagnostics.FailureAnalysis; - -public class MyBeanNotOfRequiredTypeFailureAnalyzer extends AbstractFailureAnalyzer { - - @Override - protected FailureAnalysis analyze(Throwable rootFailure, BeanNotOfRequiredTypeException cause) { - return new FailureAnalysis(getDescription(cause), getAction(cause), cause); - } - - private String getDescription(BeanNotOfRequiredTypeException ex) { - return String.format("The bean %s could not be injected as %s because it is of type %s", ex.getBeanName(), ex.getRequiredType().getName(), ex.getActualType().getName()); - } - - private String getAction(BeanNotOfRequiredTypeException ex) { - return String.format("Consider creating a bean with name %s of type %s", ex.getBeanName(), ex.getRequiredType().getName()); - } - -} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyDAO.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyDAO.java deleted file mode 100644 index ddaeb28574..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyDAO.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.baeldung.failureanalyzer; - -public class MyDAO { - -} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MySecondDAO.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MySecondDAO.java deleted file mode 100644 index 12dd73a05b..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MySecondDAO.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.failureanalyzer; - -import org.springframework.stereotype.Repository; - -@Repository("myDAO") -public class MySecondDAO { - -} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyService.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyService.java deleted file mode 100644 index 72334ca8fa..0000000000 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.failureanalyzer; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Service; - -@Service -public class MyService { - - @Resource(name = "myDAO") - private MyDAO myDAO; - -} diff --git a/spring-boot-modules/spring-boot/src/main/resources/META-INF/spring.factories b/spring-boot-modules/spring-boot/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 336477df96..0000000000 --- a/spring-boot-modules/spring-boot/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.diagnostics.FailureAnalyzer=com.baeldung.failureanalyzer.MyBeanNotOfRequiredTypeFailureAnalyzer - 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/application.properties b/spring-boot-modules/spring-boot/src/main/resources/application.properties index 7de79da574..44649fc1c0 100644 --- a/spring-boot-modules/spring-boot/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot/src/main/resources/application.properties @@ -33,12 +33,4 @@ logging.level.org.springframework=INFO servlet.name=dispatcherExample servlet.mapping=/dispatcherExampleURL -#spring.banner.charset=UTF-8 -#spring.banner.location=classpath:banner.txt -#spring.banner.image.location=classpath:banner.gif -#spring.banner.image.width= //TODO -#spring.banner.image.height= //TODO -#spring.banner.image.margin= //TODO -#spring.banner.image.invert= //TODO - contactInfoType=email \ No newline at end of file diff --git a/spring-boot-modules/spring-boot/src/main/resources/banner.txt b/spring-boot-modules/spring-boot/src/main/resources/banner.txt deleted file mode 100644 index abfa666eb6..0000000000 --- a/spring-boot-modules/spring-boot/src/main/resources/banner.txt +++ /dev/null @@ -1,14 +0,0 @@ -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@@########@@@@@@@@@@@@@@@@@@@@@@@@...@@@@@@@@@:..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -@@@@@@@@@@@@@@@@@@@@@@#. @@@@@* *@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -@@@@@@@@@@@@@@@@@#o @@@@@* @@@@@* @@@:*.*@@@@@@@: *8@@@ @@@@&:.#@. @o**@@@@**:@o*o@@:.:@@@@@:.o#@&*:@@@@ -@@@@@@@@@@@@* @@@@@* 8888 8@ @@@8 #@o 8@# .@ @@* :. @* @@@@ @. : &@ ** .@@@@ -@@@@@@@@@@. @ o@@@@@* *@@@o::& .* 8@@@@. @@ 8@@@@. @* @@@@ @. @@@& * @@@@# .@@@@ -@@@@@@@@@& @ @@@@@@* @@@@@@ 8 @@@@ .. o&&&&&&& @@ #@@@@. @* @@@@ @. @@@# * @@@@@ .@@@@ -@@@@@@@@@ @@o @@@@@@@* oooo* 8 @@@& @* @@@ # 88. 88. *& o#: @. @@@# *@ &#& .@@@@ -@@@@@@@@# @@@8 @@@@@@@* .*@@@#. *@@ @@@& :#@@@o .@@: *&@8 @o o@@: @. @@@# *@@#. :8# .@@@@ -@@@@@@@@@ @@@@ &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# o@@@@ @@@@@ -@@@@@& &@@@@ 8@@@@@@@@@8&8@@@@@#8#@@@o8@#&@@o&@@@&@@8@@&@@@@88@@8#@8&@@##@@@@@@#8@@#8@@88@@@@@ *@@@@@@@ -@@@# #@@@@#. @@@@@@@@@@@@@8@@8#o@&#@@@@o.@o*@@*.@@@.@&:8o8*@@@8&@@#@@@8@@@@8@#@@@8&@@@@@@#@@@@@@@@@@@@@@@@@@@ -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \ 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 diff --git a/spring-boot-modules/spring-boot/src/test/java/com/baeldung/failureanalyzer/FailureAnalyzerAppIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/failureanalyzer/FailureAnalyzerAppIntegrationTest.java deleted file mode 100644 index b3555f55da..0000000000 --- a/spring-boot-modules/spring-boot/src/test/java/com/baeldung/failureanalyzer/FailureAnalyzerAppIntegrationTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.baeldung.failureanalyzer; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Collection; -import java.util.stream.Collectors; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.BeanCreationException; -import org.springframework.boot.SpringApplication; - -import com.baeldung.failureanalyzer.utils.ListAppender; - -import ch.qos.logback.classic.spi.ILoggingEvent; - -public class FailureAnalyzerAppIntegrationTest { - - private static final String EXPECTED_ANALYSIS_DESCRIPTION_TITLE = "Description:"; - private static final String EXPECTED_ANALYSIS_DESCRIPTION_CONTENT = "The bean myDAO could not be injected as com.baeldung.failureanalyzer.MyDAO because it is of type com.baeldung.failureanalyzer.MySecondDAO"; - private static final String EXPECTED_ANALYSIS_ACTION_TITLE = "Action:"; - private static final String EXPECTED_ANALYSIS_ACTION_CONTENT = "Consider creating a bean with name myDAO of type com.baeldung.failureanalyzer.MyDAO"; - - @BeforeEach - public void clearLogList() { - ListAppender.clearEventList(); - } - - @Test - public void givenBeanCreationErrorInContext_whenContextLoaded_thenFailureAnalyzerLogsReport() { - try { - SpringApplication.run(FailureAnalyzerApplication.class); - } catch (BeanCreationException e) { - Collection allLoggedEntries = ListAppender.getEvents() - .stream() - .map(ILoggingEvent::getFormattedMessage) - .collect(Collectors.toList()); - assertThat(allLoggedEntries).anyMatch(entry -> entry.contains(EXPECTED_ANALYSIS_DESCRIPTION_TITLE)) - .anyMatch(entry -> entry.contains(EXPECTED_ANALYSIS_DESCRIPTION_CONTENT)) - .anyMatch(entry -> entry.contains(EXPECTED_ANALYSIS_ACTION_TITLE)) - .anyMatch(entry -> entry.contains(EXPECTED_ANALYSIS_ACTION_CONTENT)); - return; - } - throw new IllegalStateException("Context load should be failing due to a BeanCreationException!"); - } - -} diff --git a/spring-boot-modules/spring-boot/src/test/java/com/baeldung/failureanalyzer/utils/ListAppender.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/failureanalyzer/utils/ListAppender.java deleted file mode 100644 index a298f49ff5..0000000000 --- a/spring-boot-modules/spring-boot/src/test/java/com/baeldung/failureanalyzer/utils/ListAppender.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.failureanalyzer.utils; - -import java.util.ArrayList; -import java.util.List; - -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.AppenderBase; - -public class ListAppender extends AppenderBase { - - static private List events = new ArrayList<>(); - - @Override - protected void append(ILoggingEvent eventObject) { - events.add(eventObject); - } - - public static List getEvents() { - return events; - } - - public static void clearEventList() { - events.clear(); - } -} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot/src/test/resources/logback-test.xml b/spring-boot-modules/spring-boot/src/test/resources/logback-test.xml deleted file mode 100644 index 9e0f4e221f..0000000000 --- a/spring-boot-modules/spring-boot/src/test/resources/logback-test.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file