Merge remote-tracking branch 'upstream/master' into JAVA-22_spring_boot_rest_refactoring
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
<module>spring-boot-annotations</module>
|
||||
<module>spring-boot-artifacts</module>
|
||||
<module>spring-boot-autoconfiguration</module>
|
||||
<module>spring-boot-basic-customization</module>
|
||||
<module>spring-boot-bootstrap</module>
|
||||
<module>spring-boot-client</module>
|
||||
<module>spring-boot-config-jpa-error</module>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
## Spring Boot Basic Customization
|
||||
|
||||
This module contains articles about Spring Boot customization
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [How to Change the Default Port in Spring Boot](https://www.baeldung.com/spring-boot-change-port)
|
||||
- [Using Custom Banners in Spring Boot](https://www.baeldung.com/spring-boot-custom-banners)
|
||||
- [Create a Custom FailureAnalyzer with Spring Boot](https://www.baeldung.com/spring-boot-failure-analyzer)
|
||||
- [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)
|
||||
- [How to Define a Spring Boot Filter?](https://www.baeldung.com/spring-boot-add-filter)
|
||||
- [Guide to the Favicon in Spring Boot](https://www.baeldung.com/spring-boot-favicon)
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-boot-basic-customization</artifactId>
|
||||
<name>spring-boot-basic-customization</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Module For Spring Boot Basic Customization</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<!-- The main class to start by executing "java -jar" -->
|
||||
<start-class>com.baeldung.changeport.CustomApplication</start-class>
|
||||
</properties>
|
||||
</project>
|
||||
+2
-4
@@ -1,10 +1,8 @@
|
||||
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;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class FilterConfig {
|
||||
+4
-5
@@ -1,16 +1,15 @@
|
||||
package com.baeldung.bootcustomfilters.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.baeldung.bootcustomfilters.model.User;
|
||||
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;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Rest controller for User
|
||||
+5
-11
@@ -1,21 +1,15 @@
|
||||
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;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A servlet filter to log request and response
|
||||
* The logging implementation is pretty native and for demonstration only
|
||||
+4
-10
@@ -1,20 +1,14 @@
|
||||
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;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A filter to create transaction before and commit it once request completes
|
||||
* The current implemenatation is just for demo
|
||||
+1
-3
@@ -2,10 +2,8 @@ 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")
|
||||
@SpringBootApplication(scanBasePackages = "com.baeldung.errorhandling")
|
||||
public class ErrorHandlingApplication {
|
||||
|
||||
public static void main(String [] args) {
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package com.baeldung.failureanalyzer;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
|
||||
@SpringBootApplication
|
||||
public class FailureAnalyzerApplication {
|
||||
@RolesAllowed("*")
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package com.baeldung.failureanalyzer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class MyService {
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.baeldung.favicon;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class FaviconApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(FaviconApplication.class, args);
|
||||
}
|
||||
}
|
||||
+7
-6
@@ -1,8 +1,4 @@
|
||||
package com.baeldung.springbootmvc.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
package com.baeldung.favicon.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -14,8 +10,13 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
||||
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class FaviconConfiguration {
|
||||
|
||||
@Bean
|
||||
public SimpleUrlHandlerMapping myFaviconHandlerMapping() {
|
||||
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
|
||||
@@ -33,7 +34,7 @@ public class FaviconConfiguration {
|
||||
return requestHandler;
|
||||
}
|
||||
|
||||
// @Controller
|
||||
// @Controller
|
||||
static class FaviconController {
|
||||
|
||||
@RequestMapping(value = "favicon.ico", method = RequestMethod.GET)
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#server
|
||||
server.port=9000
|
||||
spring.mvc.servlet.path=/
|
||||
server.servlet.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
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
#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
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
+7
@@ -0,0 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<h1> Sorry, we couldn't find the page you were looking for. </h1>
|
||||
<p><a href="/">Go Home</a></p>
|
||||
</body>
|
||||
</html>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user