@SuppressWarnings("unchecked")
    public static <T> T getOptionalBean(HttpSecurity httpSecurity, ResolvableType type) {
        ApplicationContext context = httpSecurity.getSharedObject(ApplicationContext.class);
        String[] names = context.getBeanNamesForType(type);
        if (names.length > 1) {
            throw new NoUniqueBeanDefinitionException(type, names);
        }
        return names.length == 1 ? (T) context.getBean(names[0]) : null;
    }
@author: zlt
@date: 2023/11/16
<p>
Blog: https://zlt2000.gitee.io
Github: https://github.com/zlt2000
zlt-uaa/src/main/java/com/central/oauth/utils/OAuth2ConfigurerUtils.java