本文主要是介绍打印所有SpringBoot载入的bean,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
@SpringBootApplication
public class Application {private static final Logger logger = LoggerFactory.getLogger(Application.class);public static void main(String[] args) {ApplicationContext ctx = SpringApplication.run(Application.class, args);//所有的bean,参考:http://412887952-qq-com.iteye.com/blog/2314051String[] beanNames = ctx.getBeanDefinitionNames();//String[] beanNames = ctx.getBeanNamesForAnnotation(RestController.class);//所有添加该注解的beanlogger.info("bean总数:{}", ctx.getBeanDefinitionCount());int i = 0;for (String str : beanNames) {logger.info("{},beanName:{}", ++i, str);}}
}
这篇关于打印所有SpringBoot载入的bean的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!