我是靠谱客的博主 含糊翅膀,最近开发中收集的这篇文章主要介绍[Spring boot] CommandLineRunner and Autowired,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
Previously we use Application Context to get Bean and Dependenies injection. It is actually easier to use 'CommonLineRunner'.
Main beneift is we can use @Autowired.
@SpringBootApplication public class SpringAopApplication implements CommandLineRunner{ private Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private Business1 business1; @Autowired private Business2 business2; public static void main(String[] args) { SpringApplication.run(SpringAopApplication.class, args); } @Override public void run(String... args) throws Exception { logger.info(business1.calculateSomething()); logger.info(business2.calculateSomething()); } }
转载于:https://www.cnblogs.com/Answer1215/p/10865277.html
最后
以上就是含糊翅膀为你收集整理的[Spring boot] CommandLineRunner and Autowired的全部内容,希望文章能够帮你解决[Spring boot] CommandLineRunner and Autowired所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复