| 这一部分深入研究了解 Spring boot 的细节。在这里你可以了解你可能想要使用和自定义的关键特性。如果你还没有准备好这样做,你可能需要阅读 章节 II, “新手入门” 和 章节 III, “使用 Spring Boot” 部分,这样你就有基础部分的良好基础。 
                             public static void main(String[] args) { SpringApplication.run(MySpringConfiguration.class, args); } 当你的应用程序启动时,你应该可以看到类似下面输出的一些内容: . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: v2.1.0.BUILD-SNAPSHOT 2013-07-31 00:08:16.117 INFO 56603 --- [ main] o.s.b.s.app.SampleApplication : Starting SampleApplication v0.1.0 on mycomputer with PID 56603 (/apps/myapp.jar started by pwebb) 2013-07-31 00:08:16.166 INFO 56603 --- [ main] ationConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6e5a8246: startup date [Wed Jul 31 00:08:16 PDT 2013]; root of context hierarchy 2014-03-04 13:09:54.912 INFO 41370 --- [ main] .t.TomcatServletWebServerFactory : Server initialized with port: 8080 2014-03-04 13:09:56.501 INFO 41370 --- [ main] o.s.b.s.app.SampleApplication : Started SampleApplication in 2.992 seconds (JVM running for 3.658) 
                            默认情况下,显示了  
                                如果你的应用程序启动失败,注册的  *************************** APPLICATION FAILED TO START *************************** Description: Embedded servlet container failed to start. Port 8080 was already in use. Action: Identify and stop the process that's listening on port 8080 or configure this application to listen on another port. 
 
                                如果没有失败分析器能够处理异常,你仍可以显示完整的条件报告,以便更好地理解错误所在。为此,你需要为  
                                例如,如果你使用  $ java -jar myproject-0.0.1-SNAPSHOT.jar --debug 
                                在启动时打印的横幅可以通过在你的类路径中添加一个  
                                在你的  表格 23.1. Banner 变量 
 
 
                                你还可以使用  
                                打印横幅被注册为一个单独的 bean,名称如下: 
 
                                如果  public static void main(String[] args) { SpringApplication app = new SpringApplication(MySpringConfiguration.class); app.setBannerMode(Banner.Mode.OFF); app.run(args); } 
 
                                也可以通过使用  
                                有关配置选项的完整列表,请参阅  
                                如果你需要构建一个  
                                 new SpringApplicationBuilder() .sources(Parent.class) .child(Application.class) .bannerMode(Banner.Mode.OFF) .run(args); 
 
                                除了通常的 Spring Framework 事件之外,如  
 应用程序事件按以下顺序发送,如果你的应用程序运行: 
 
 
                                应用程序事件是使用 Spring Framework 的事件发布机制发送的。这种机制的一部分确保子上下文中发布给监听器的事件也会发布到一些父上下文中的监听器。因此,如果你的应用程序使用  
                                为了允许监听器区分其上下文的事件和派生上下文的事件,它应该请求注入其应用程序上下文,然后将注入的上下文与事件的上下文进行比较。上下文可以通过实现  
                                 
 
                                这意味着,如果你在同一个应用程序中使用 Spring MVC 和 Spring WebFlux 的新  
                                还可以调用  
 
                                如果你需要访问传递给  import org.springframework.boot.*; import org.springframework.beans.factory.annotation.*; import org.springframework.stereotype.*; @Component public class MyBean { @Autowired public MyBean(ApplicationArguments args) { boolean debug = args.containsOption("debug"); List<String> files = args.getNonOptionArgs(); // if run with "--debug logfile.txt" debug=true, files=["logfile.txt"] } } 
 
                                如果你需要在  
                                 import org.springframework.boot.*; import org.springframework.stereotype.*; @Component public class MyBean implements CommandLineRunner { public void run(String... args) { // Do something... } } 
                                如果定义了几个  
                                每个  
                                此外,如果希望  @SpringBootApplication public class ExitCodeApplication { @Bean public ExitCodeGenerator exitCodeGenerator() { return () -> 42; } public static void main(String[] args) { System.exit(SpringApplication .exit(SpringApplication.run(ExitCodeApplication.class, args))); } } 
                                此外, 
                                可以通过指定  
 
 |