相关文章推荐
傻傻的佛珠  ·  SpringBoot ...·  12 月前    · 
public class MyCommandLineRunner implements CommandLineRunner { @Override public void run ( String . . . var1 ) throws Exception {

服务启动会执行 commandLineRanner 实例。那如何忽略 commandLineRanner 实例这个 @component 呢?
其实很简单,在 commandLineRanne r实例上加注解 @TestConfiguration 或者 @TestComponent 就可以忽略。

官方文档链接: http://docs.spring.io/spring-boot/docs/1.5.1.RELEASE/reference/htmlsingle/#boot-features-testing