spring移除容器bean

    public void removeBeans(List<String> beans) {
        ConfigurableApplicationContext context = (ConfigurableApplicationContext) applicationContext;
        if (context == null) {
            return;
        }
        DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) context.getBeanFactory();
        for (String bean : beans) {
            beanFactory.removeBeanDefinition(bean);
        }
    }

 

posted @ 2023-07-31 16:42  鸭猪是的念来过倒  阅读(238)  评论(0编辑  收藏  举报