customerSecurityConfig.class
Код: Выделить всё
@Configuration
@Order(2)
public class customerSecurityConfig {
@Bean
public AuthenticationManager customerAuthenticationManager(AuthenticationConfiguration customerConfig) throws Exception {
return customerConfig.getAuthenticationManager();
}
//...
}
Код: Выделить всё
@Configuration
@Order(2)
public class adminSecurityConfig {
@Bean
public AuthenticationManager adminAuthenticationManager(AuthenticationConfiguration config) throws Exception {
return config.getAuthenticationManager();
}
//...
}
AdminAuthenticationSecurity.class:
Код: Выделить всё
@Server
@RequiredArgsConstructor
public class AdminAuthenticationService {
@Qualifier("adminAuthenticationManager")
private final AuthenticationManager adminAuthenticationManager;
public AuthenticationResponse register() {
//...
}
public AuthenticationResponse authenticate () {
//...
}
}
Код: Выделить всё
@Service
@RequiredArgsConstructor
public class CustomerAuthenticationService {
@Qualifier("customerAuthenticationManager")
private final AuthenticationManager customerAuthenticationManager;
public AuthenticationResponse register() {
//...
}
public AuthenticationResponse authenticate() {
//...
}
}
org.springframework.beans.BeanInstantiationException : Не удалось создать экземпляр [org.springframework.security.authentication.AuthenticationManager]: фабричный методcustomerAuthenticationManager выдал исключение с сообщением: найдены 2 bean-компонента для интерфейса типа org.springframework.security.authentication.AuthenticationManager, но ни один из них не помечен как основной
как устранить эту ошибку?
Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/781 ... pring-boot