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.
Note
Spring Boot提供了大量的
FailureAnalyzer
实现,当然你也可以增加你自己的FailureAnalyzer.
如果未提供错误分析器去处理异常,应用仍然能显示完全的条件报告帮助你更好的理解到底哪里出问题.如果需要这么做,
你需要设置debug=true
或者为org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener
使能Debug日志级别.
例如,如果你是通过jave -jar
命令运行程序,你可以使能debug
选项如下所示:
$ java -jar myproject-0.0.1-SNAPSHOT.jar --debug