From 23a8ac3cc014e4ba14fb4829fc876ead63b3bdbb Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sun, 17 Jun 2018 10:03:56 +0300 Subject: [PATCH] update to spring 5 --- spring-security-mvc-custom/pom.xml | 12 ++++++------ .../src/main/java/org/baeldung/spring/MvcConfig.java | 6 ++---- .../java/org/baeldung/spring/SecSecurityConfig.java | 2 ++ .../org/baeldung/web/controller/LoginController.java | 3 ++- .../src/main/resources/webSecurityConfig.xml | 10 +++++----- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 52ec1e4ef0..e50304aa1b 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-spring-4 + parent-spring-5 0.0.1-SNAPSHOT - ../parent-spring-4 + ../parent-spring-5 @@ -193,26 +193,26 @@ - 4.2.6.RELEASE + 5.0.6.RELEASE 5.2.5.Final 5.1.40 - 5.3.3.Final + 5.4.1.Final 3.1.0 1.2 19.0 3.5 - 2.9.1 + 2.9.4 4.5.2 4.4.5 - 2.9.0 + 3.0.7 2.6 diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java index 3b97afc22d..db6141d43e 100644 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java @@ -10,14 +10,14 @@ import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; @EnableWebMvc @Configuration @ComponentScan("org.baeldung.web.controller") -public class MvcConfig extends WebMvcConfigurerAdapter { +public class MvcConfig implements WebMvcConfigurer { public MvcConfig() { super(); @@ -27,8 +27,6 @@ public class MvcConfig extends WebMvcConfigurerAdapter { @Override public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - registry.addViewController("/anonymous.html"); registry.addViewController("/login.html"); diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-mvc-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 4da114c78b..e9d5bc4f70 100644 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -6,6 +6,8 @@ import org.springframework.context.annotation.ImportResource; @Configuration @ImportResource({ "classpath:webSecurityConfig.xml" }) public class SecSecurityConfig { + + public SecSecurityConfig() { super(); diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/web/controller/LoginController.java b/spring-security-mvc-custom/src/main/java/org/baeldung/web/controller/LoginController.java index c67a6f667e..99bf345a41 100644 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/web/controller/LoginController.java +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/web/controller/LoginController.java @@ -1,5 +1,6 @@ package org.baeldung.web.controller; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -18,7 +19,7 @@ import org.springframework.web.bind.annotation.RequestParam; @RequestMapping(value = "/custom") public class LoginController { - @Autowired + @Resource(name="authenticationManager") private AuthenticationManager authManager; public LoginController() { diff --git a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml index f2ecaba5c8..e79e14abeb 100644 --- a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml @@ -2,9 +2,9 @@ @@ -24,11 +24,11 @@ - + - - + +