import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
@Bean
public CommandLineRunner run() {
return args -> {
try {
// 业务逻辑代码
//出错可以捕获异常,记录日志,但不要抛出异常
} catch (Exception e) {
// 处理异常,记录日志等
}
};
}
}