From d94ec51a944baacfd166138e97a9abfc8c3281a0 Mon Sep 17 00:00:00 2001 From: "bstewart@gitlab.retail.bytes.co.za" Date: Sun, 9 Sep 2018 10:44:59 +0200 Subject: [PATCH 1/7] Upgrade from spring-boot 1.5.3 to 2.0.4 Modify WebSecurityConfig for spring-boot upgrade. Modify WebApplication class import of SpringBootServletInitializer for spring-boot upgrade. Change packaging from 35MB war to 22kb thin jar. --- pom.xml | 26 ++++++++++++------- .../com/hellokoding/auth/WebApplication.java | 2 +- .../hellokoding/auth/WebSecurityConfig.java | 9 ++++++- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 7059011..22e036e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,11 +4,11 @@ auth auth auth - war + jar org.springframework.boot spring-boot-starter-parent - 1.3.5.RELEASE + 2.0.4.RELEASE @@ -35,19 +35,11 @@ org.hsqldb hsqldb - runtime - - - - org.springframework.boot - spring-boot-starter-tomcat - provided org.apache.tomcat.embed tomcat-embed-jasper - provided @@ -60,6 +52,20 @@ org.springframework.boot spring-boot-maven-plugin + + + + repackage + + + + + + org.springframework.boot.experimental + spring-boot-thin-layout + 1.0.14.RELEASE + + diff --git a/src/main/java/com/hellokoding/auth/WebApplication.java b/src/main/java/com/hellokoding/auth/WebApplication.java index eed3887..0693113 100644 --- a/src/main/java/com/hellokoding/auth/WebApplication.java +++ b/src/main/java/com/hellokoding/auth/WebApplication.java @@ -3,7 +3,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.context.web.SpringBootServletInitializer; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @SpringBootApplication public class WebApplication extends SpringBootServletInitializer { diff --git a/src/main/java/com/hellokoding/auth/WebSecurityConfig.java b/src/main/java/com/hellokoding/auth/WebSecurityConfig.java index efcd553..4679676 100644 --- a/src/main/java/com/hellokoding/auth/WebSecurityConfig.java +++ b/src/main/java/com/hellokoding/auth/WebSecurityConfig.java @@ -3,6 +3,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; @@ -37,7 +38,13 @@ protected void configure(HttpSecurity http) throws Exception { } @Autowired - public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { + public void configure(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder()); } + + @Bean + @Override + public AuthenticationManager authenticationManagerBean() throws Exception { + return super.authenticationManagerBean(); + } } \ No newline at end of file From ccac12be1c24102c0d4c84c231fd847a79e730a6 Mon Sep 17 00:00:00 2001 From: "bstewart@gitlab.retail.bytes.co.za" Date: Sun, 9 Sep 2018 10:59:53 +0200 Subject: [PATCH 2/7] Update README.md with thin jar launch command. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6dfaa8e..cca1a09 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,5 @@ https://hellokoding.com/registration-and-login-example-with-spring-security-spri ## Run ```mvn clean spring-boot:run``` +To run the standalone thin jar: +```mvn clean package && java -jar target/auth-2.0.4.RELEASE.jar``` From 0de81a9adae19342c26b20c931df2fbc1ece4a24 Mon Sep 17 00:00:00 2001 From: "bstewart@gitlab.retail.bytes.co.za" Date: Mon, 10 Sep 2018 21:19:23 +0200 Subject: [PATCH 3/7] Update README.md with thin jar launch command. --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cca1a09..52e9564 100644 --- a/README.md +++ b/README.md @@ -17,5 +17,9 @@ https://hellokoding.com/registration-and-login-example-with-spring-security-spri ## Run ```mvn clean spring-boot:run``` + To run the standalone thin jar: -```mvn clean package && java -jar target/auth-2.0.4.RELEASE.jar``` +``` +mvn clean package +java -jar target/auth-2.0.4.RELEASE.jar +``` From 3a36c7c30b112adb3629ae3e57196f110c8ba322 Mon Sep 17 00:00:00 2001 From: Bruce Stewart Date: Mon, 10 Jan 2022 00:37:57 +0200 Subject: [PATCH 4/7] Upgrade to spring-boot 2.6.2 --- pom.xml | 4 ++-- src/main/java/com/hellokoding/auth/WebSecurityConfig.java | 6 ------ .../hellokoding/auth/service/UserDetailsServiceImpl.java | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 22e036e..2c5f0c8 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.4.RELEASE + 2.6.2 @@ -63,7 +63,7 @@ org.springframework.boot.experimental spring-boot-thin-layout - 1.0.14.RELEASE + 1.0.28.RELEASE diff --git a/src/main/java/com/hellokoding/auth/WebSecurityConfig.java b/src/main/java/com/hellokoding/auth/WebSecurityConfig.java index 4679676..71674aa 100644 --- a/src/main/java/com/hellokoding/auth/WebSecurityConfig.java +++ b/src/main/java/com/hellokoding/auth/WebSecurityConfig.java @@ -4,7 +4,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; @@ -37,11 +36,6 @@ protected void configure(HttpSecurity http) throws Exception { .permitAll(); } - @Autowired - public void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder()); - } - @Bean @Override public AuthenticationManager authenticationManagerBean() throws Exception { diff --git a/src/main/java/com/hellokoding/auth/service/UserDetailsServiceImpl.java b/src/main/java/com/hellokoding/auth/service/UserDetailsServiceImpl.java index 36a6490..ef9ff93 100644 --- a/src/main/java/com/hellokoding/auth/service/UserDetailsServiceImpl.java +++ b/src/main/java/com/hellokoding/auth/service/UserDetailsServiceImpl.java @@ -15,7 +15,7 @@ import java.util.HashSet; import java.util.Set; -@Service +@Service(value = "userDetailsService") public class UserDetailsServiceImpl implements UserDetailsService{ @Autowired private UserRepository userRepository; From 675e8be9ee32db1cb34219f7e34c248934b331ca Mon Sep 17 00:00:00 2001 From: Bruce Stewart Date: Mon, 10 Jan 2022 00:43:50 +0200 Subject: [PATCH 5/7] Update to --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 52e9564..3f89c87 100644 --- a/README.md +++ b/README.md @@ -21,5 +21,5 @@ https://hellokoding.com/registration-and-login-example-with-spring-security-spri To run the standalone thin jar: ``` mvn clean package -java -jar target/auth-2.0.4.RELEASE.jar +java -jar target/auth-2.6.2.jar ``` From 7a15d5f31b95a890800644fd0278dac45292441a Mon Sep 17 00:00:00 2001 From: Bruce Stewart Date: Mon, 10 Jan 2022 01:05:46 +0200 Subject: [PATCH 6/7] Remove the spring-boot-thin-layout dependency --- pom.xml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/pom.xml b/pom.xml index 2c5f0c8..9ebb216 100644 --- a/pom.xml +++ b/pom.xml @@ -52,20 +52,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - - - - org.springframework.boot.experimental - spring-boot-thin-layout - 1.0.28.RELEASE - - From f81471921946d3435b02c577313d8fe8cb47ee62 Mon Sep 17 00:00:00 2001 From: Bruce Stewart Date: Mon, 10 Jan 2022 01:08:02 +0200 Subject: [PATCH 7/7] Update README (not running a thin jar) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f89c87..5bbd292 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ https://hellokoding.com/registration-and-login-example-with-spring-security-spri ## Run ```mvn clean spring-boot:run``` -To run the standalone thin jar: +To run the standalone jar: ``` mvn clean package java -jar target/auth-2.6.2.jar