📜  显示所有 Spring Boot bean - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:11.863000             🧑  作者: Mango

代码示例1
@Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return args -> {

            System.out.println("Let's inspect the beans provided by Spring Boot:");

            String[] beanNames = ctx.getBeanDefinitionNames();
            Arrays.sort(beanNames);
            for (String beanName : beanNames) {
                System.out.println("my beans "+beanName);
            }
        };
    }