@Slf4j
@RestController
@EnableFeignClients
@EnableDiscoveryClient
@Configuration
@SpringBootApplication
@RefreshScope
public class Application implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
public void run(String... args) throws Exception {
log.info("-------------------------Application Sart Success-------------------------");
}
}
打印日志:
自定义类实现CommandLineRunner接口,或者去掉启动类上的@RefreshScope注解即可解决这个问题,另外在其他bean上使用@RefreshScope不会导致启动类的CommandLineRunner执行两次。