23.1 Startup Failure

如果您的应用程序无法启动,注册的FailureAnalyzers将会有机会提供一个具体的错误消息和处理该问题的解决方法. 例如,如果您在已使用的8080端口上启动一个web应用,您应该能看到类似下面的信息:

  1. ***************************
  2. APPLICATION FAILED TO START
  3. ***************************
  4. Description:
  5. Embedded servlet container failed to start. Port 8080 was already in use.
  6. Action:
  7. Identify and stop the process that's listening on port 8080 or configure this application to listen on
  8. another port.

Note

Spring Boot提供了大量的FailureAnalyzer实现,当然你也可以增加你自己的FailureAnalyzer.

如果未提供错误分析器去处理异常,应用仍然能显示完全的条件报告帮助你更好的理解到底哪里出问题.如果需要这么做, 你需要设置debug=true或者为org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener使能Debug日志级别.

例如,如果你是通过jave -jar命令运行程序,你可以使能debug选项如下所示:

  1. $ java -jar myproject-0.0.1-SNAPSHOT.jar --debug