diff --git a/README.md b/README.md index 6dfaa8e..5bbd292 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,9 @@ https://hellokoding.com/registration-and-login-example-with-spring-security-spri ## Run ```mvn clean spring-boot:run``` + +To run the standalone jar: +``` +mvn clean package +java -jar target/auth-2.6.2.jar +``` diff --git a/pom.xml b/pom.xml index 7059011..9ebb216 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.6.2 @@ -35,19 +35,11 @@ org.hsqldb hsqldb - runtime - - - - org.springframework.boot - spring-boot-starter-tomcat - provided org.apache.tomcat.embed tomcat-embed-jasper - provided 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..71674aa 100644 --- a/src/main/java/com/hellokoding/auth/WebSecurityConfig.java +++ b/src/main/java/com/hellokoding/auth/WebSecurityConfig.java @@ -3,7 +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.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.authentication.AuthenticationManager; 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; @@ -36,8 +36,9 @@ protected void configure(HttpSecurity http) throws Exception { .permitAll(); } - @Autowired - public void configureGlobal(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 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;