How to make Spring server to start even if database is down?

后端 未结 4 947
余生分开走
余生分开走 2021-02-07 00:49

I\'m using a Spring Boot(1.4.7) & MyBatis.

spring.main1.datasource.url=jdbc:mariadb://192.168.0.11:3306/testdb?useUnicode=true&characterEncoding=utf8&         


        
4条回答
  •  有刺的猬
    2021-02-07 01:17

    You can set:

    spring.datasource.continue-on-error=true
    

    in your application.properties.

    According to the Spring Boot 2.2.4 user guide:

    By default, Spring Boot enables the fail-fast feature of the Spring JDBC initializer. This means that, if the scripts cause exceptions, the application fails to start. You can tune that behavior by setting spring.datasource.continue-on-error.

提交回复
热议问题