Does Liquibase runs before registering all the beans in spring boot application?

Pranjal Kumar :

I have integrated Liquibase with my spring Boot application. The one confusion which I have is that - does Liquibase run before registering all the beans. If we want to fetch some property from the DB in the bean declaration method and that property is written by the sql script which will be executed by Liquibase. So, which of the two things will happen first?

I do know that liquibase automatically gets integrated to the startup of the spring boot application i.e, it runs everytime, the application runs. But, does it get loaded before loading other beans of the same application?

My liquibase dependency :

<dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
            <version>3.8.2</version>
</dependency>
htshame :

So, which of the two things will happen first?

  1. Liquibase runs it's scripts.
  2. Spring-Boot initializes your beans.

So you should be able to get data (which Liquibase has just inserted) from database during bean initialization.

But as was suggested in the comments, you should try it yourself and add logs to your bean initialization methods. This will give you a way better understanding of Spring-Boot applications start-up process.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=421290&siteId=1