SpringBoot: reslove circular dependancie
- remove lazy load
This commit is contained in:
parent
25b0b34b8d
commit
23560c8326
@ -1,7 +1,5 @@
|
||||
package djmil.cordacheckers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
@ -12,13 +10,13 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class ApiUserDetailsService implements UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private PasswordEncoder encoder;
|
||||
private final PasswordEncoder encoder;
|
||||
private final ApiUserShortHashService apiUserShortHash;
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
ApiUserShortHashService apiUserShortHash;
|
||||
public ApiUserDetailsService(PasswordEncoder encoder, ApiUserShortHashService apiUserShortHash) {
|
||||
this.encoder = encoder;
|
||||
this.apiUserShortHash = apiUserShortHash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiUserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package djmil.cordacheckers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.security.authentication.AuthenticationProvider;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
@ -13,12 +11,13 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class CustomAuthenticationProvider implements AuthenticationProvider {
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private PasswordEncoder encoder;
|
||||
private final PasswordEncoder encoder;
|
||||
private final ApiUserDetailsService userDetailsService;
|
||||
|
||||
@Autowired
|
||||
private ApiUserDetailsService userDetailsService;
|
||||
public CustomAuthenticationProvider(PasswordEncoder encoder, ApiUserDetailsService userDetailsService) {
|
||||
this.userDetailsService = userDetailsService;
|
||||
this.encoder = encoder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package djmil.cordacheckers;
|
||||
|
||||
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;
|
||||
@ -22,12 +21,8 @@ public class SecurityConfig {
|
||||
return PasswordEncoderFactories.createDelegatingPasswordEncoder();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
CustomAuthenticationProvider authenticationProvider;
|
||||
|
||||
@Autowired
|
||||
public void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.authenticationProvider(authenticationProvider);
|
||||
public void configure(AuthenticationManagerBuilder auth, CustomAuthenticationProvider authenticationProvider) throws Exception {
|
||||
auth.authenticationProvider(authenticationProvider);
|
||||
}
|
||||
|
||||
// @Bean
|
||||
|
Loading…
Reference in New Issue
Block a user