23.1 Startup failure
如果应用启动失败,注册的FailureAnalyzers就有机会提供一个特定的错误信息,及具体的解决该问题的动作。例如,如果在8080端口启动一个web应用,而该端口已被占用,那你应该可以看到类似如下的内容:
**************************
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.
Spring Boot提供很多的FailureAnalyzer实现,你自己实现也很容易
如果没有可用于处理该异常的失败分析器(failure analyzers),你仍然可以展示完整的auto-configuration报告以便更好的查看出问题的地方,为此,你需要开启org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer
的debug
属性或开启DEBUG logging
例如,使用java -jar运行应用时,你可以通过如下命令启用debug属性:
$ java -jar myproject-0.0.1-SNAPSHOT.jar --debug