去掉 pom依赖里引入模块 不要的 @Bean @Configuration

代码

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.stereotype.Component;


@Component
public class RemoveRegistryBeanFactoryPostProcessor implements BeanDefinitionRegistryPostProcessor {

    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
        String[] names = registry.getBeanDefinitionNames();
        for (String name : names) {
            if (name.contains("xxxBean")
                    || name.("xxxConfig")
                   

            ) {
                registry.removeBeanDefinition(name);
                System.out.println(name);

            }

        }
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    }
}

相关推荐

  1. 去掉 pom依赖引入模块 不要 @Bean @Configuration

    2024-04-24 13:58:03       37 阅读
  2. SpringBoot如何修改pom依赖默认版本号

    2024-04-24 13:58:03       44 阅读
  3. IDEA中pom中打包引入jar包

    2024-04-24 13:58:03       66 阅读
  4. org.openjdk.jmh pom 引用

    2024-04-24 13:58:03       53 阅读
  5. PythonOS模块

    2024-04-24 13:58:03       45 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-24 13:58:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-24 13:58:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-24 13:58:03       87 阅读
  4. Python语言-面向对象

    2024-04-24 13:58:03       96 阅读

热门阅读

  1. Ant-design中表单多级对象做嵌套表单校验

    2024-04-24 13:58:03       38 阅读
  2. springboot @Validated的概念以及实战

    2024-04-24 13:58:03       39 阅读
  3. MySQL数据库-左右外链接

    2024-04-24 13:58:03       32 阅读
  4. 数据库审计

    2024-04-24 13:58:03       30 阅读
  5. keyguardManager.isKeyguardLocked()在oppo手机上返回错误

    2024-04-24 13:58:03       35 阅读
  6. LeetCode 0039.组合总和:回溯 + 剪枝

    2024-04-24 13:58:03       35 阅读
  7. 神经网络进阶学习文章(一)

    2024-04-24 13:58:03       41 阅读
  8. python 常用库

    2024-04-24 13:58:03       32 阅读
  9. spring提高并发能力

    2024-04-24 13:58:03       38 阅读
  10. linux redis 开机自启

    2024-04-24 13:58:03       38 阅读
  11. 2024.4.22力扣每日一题——组合总和 Ⅳ

    2024-04-24 13:58:03       25 阅读
  12. 【LeetCode热题100】【多维动态规划】编辑距离

    2024-04-24 13:58:03       35 阅读