赞
踩
import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; @Slf4j public class StartupRunner implements CommandLineRunner { @Autowired MyService myService; @Override public void run(String... args) throws Exception { log.info("startup runner"); log.info("args:{}",args); myService.doJob(); log.info("task finished"); } }
iimport com.daye.travel.process.getodata.service.StartupRunner; import org.springframework.boot.ExitCodeGenerator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.context.annotation.Bean; @SpringBootApplication @EnableDiscoveryClient public class GetodataApplication { @Bean public ExitCodeGenerator exitCodeGenerator() { return () -> 42; } public static void main(String[] args) { System.exit(SpringApplication .exit(SpringApplication.run(GetodataApplication.class, args))); } @Bean public StartupRunner startupRunner() { return new StartupRunner(); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。