title: Wait for database connection in Spring Boot without an exception
body: <p>I want to create a microservice with Spring Boot. For persistence i use a mariadb database. To wait for the database which is running in a docker container, i implemented the following code like shown <a href="https://deinum.biz/2020-06-30-Wait-for-database-startup/" rel="nofollow noreferrer">here</a>:</p>
  <pre><code>@Bean
      public DatabaseStartupValidator databaseStartupValidator(DataSource dataSource) {
          var dsv = new DatabaseStartupValidator();
          dsv.setDataSource(dataSource);
          dsv.setTimeout(60);
          dsv.setInterval(7);
          dsv.setValidationQuery(DatabaseDriver.MYSQL.getValidationQuery());
          return dsv;
      }
  </code></pre>
  <p>The code is working very well, my application is now waiting for the database connection. But i get an exception at startup of the application:</p>
  <pre><code>java.sql.SQLNonTransientConnectionException: Could not connect to Host ....
  ...
  ...
  ...
  </code></pre>
  <p>In the next line i get an information, that it will wait for the database:</p>
  <p><code>021-04-07 21:29:40.816  INFO 16569 --- [           main] o.s.j.support.DatabaseStartupValidator   : Database has not started up yet - retrying in 7 seconds (timeout in 57.65 seconds)</code></p>
  <p>After that the application is starting as expected. So i think everything is working fine, but what i have to do to suppress the Exception? In the linked <a href="https://deinum.biz/2020-06-30-Wait-for-database-startup/" rel="nofollow noreferrer">article</a> it should work without an exception. Do i have to implement the &quot;dependsOnPostProcessor&quot; function? Which dependency i have to use? Sorry, possible a dumb question, i am new to spring boot.</p>