@Bean
    public AuthenticationManager authenticationManager(HttpSecurity security) throws Exception {
        return security
                .getSharedObject(AuthenticationManagerBuilder.class)
                .userDetailsService(authorizeService)
                .and()
                .build();
    }

Is there a Lambda DSL alternative?

Comment From: marcusdacoregio

Hi @awxiaoxian2020, we do not really recommend publishing an AuthenticationManager using the AuthenticationManagerBuilder as it can lead to some unexpected behaviors. Instead, prefer creating the AuthenticationManager by yourself, as mentioned here.