1. 程式人生 > 其它 >springboot啟動時的一些問題

springboot啟動時的一些問題

  • 具體報錯如下:
[main] INFO  org.apache.catalina.core.StandardService - Starting service [Tomcat]
[main] INFO  org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.52]
[main] INFO  o.a.c.c.C.[Tomcat].[localhost].[/earlywarning] - Initializing Spring embedded WebApplicationContext
[main] INFO  o.s.b.w.s.c.ServletWebServerApplicationContext 
- Root WebApplicationContext: initialization completed in 1546 ms [main] INFO ru.yandex.clickhouse.ClickHouseDriver - Driver registered [main] INFO org.apache.catalina.core.StandardService - Stopping service [Tomcat] [main] INFO o.s.b.a.l.ConditionEvaluationReportLoggingListener - Error starting ApplicationContext. To display the conditions report re
-run your application with 'debug' enabled.
  • 排查過程:

在啟動專案時發現日誌中輸出瞭如上資訊,但是奇怪的是本地執行正常,沒有出現這樣的報錯,經過比對測試環境配置檔案和生產環境配置檔案發現,在配置檔案中

新加的兩個外部介面的欄位名不一致,導致生產環境程式碼中讀取不到這個值(程式碼如下):

@Value("${boot.warningToFault.path}")
private String warnToFaultPath;
  • 解決方法:

將兩個環境中該欄位名統一即可。

  • 反思:

必須保持一致的欄位或者程式碼儘量複製,避免手敲產生的錯誤,如上面的例子、或者是和mapper檔案對應的XML檔名等。