spring boot的环境搭建
spring boot的启动入口的方式
package com.zcp.springstart;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class App {
@Bean
public Runnable createRunnable(){
return new Runnable() {
@Override
public void run() {
System.out.println(">>>>>>>>>>>>runn---------");
}
};
}
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(App.class, args);
context.getBean(Runnable.class).run();
}
}
说明:springboot的启动入口类,默认为配置类,故可以在该类中注入bean。