Hello there!

I'm facing an issue to integrate Spring Boot with liquibase-mongodb V. 4.8.0, Spring framework doesn't invoke the liquibase to apply the changes at all.

I have added to gradle library:

// liquibase
implementation 'org.liquibase:liquibase-core:4.8.0'
implementation 'org.liquibase.ext:liquibase-mongodb:4.8.0'

Here is application.properties

spring.liquibase.enabled=true
spring.liquibase.change-log=classpath:/db.migration/V1_0_1_initial_database.xml
spring.liquibase.user=user
spring.liquibase.password=123
spring.liquibase.url=${spring.data.mongodb.uri}

Any urgent solution, I really appreciate.

Comment From: wilkinsona

Please provide a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: sayseakleng

Hello @wilkinsona !

Here is my example: demo-3.zip

I can do a quick trick with this class com.example.demo.config.LiquibaseConfiguration to enable Liquibase, but I commented it out to get your investigation. I prefer spring.liquibase.enabled=true to automatically load Liquibase.

Thank you so much for your quick response.

Comment From: wilkinsona

Thanks for the sample. Spring Boot's auto-configuration for Liquibase is built around Liquibase's SpringLiquibase class which depends upon JDBC and assumes the use of a DataSource. By contrast, rather than using a DataSource Liquibase's Mongo extension is built around Liquibase's Database abstraction. The two are not interchangeable so attempting to initialise a NoSQL database won't work.

You don't see a failure at the moment as we use a class from spring-jdbc as part of setting up SpringLiquibase. You don't have that module on the classpath which causes the auto-configuration to back off. If you add a dependency on spring-jdbc, the auto-configuration will run but it will then fail as a DataSource cannot be created from a Mongo URL.

Our Liquibase support is documented as part of a section on SQL database initialization. Given this, things are working as intended. We can consider reworking our auto-configuration for Liquibase to cover NoSQL databases, but it would raise a number of questions. For example, if an app was using both an SQL database and a no SQL database and they wanted Liquibase to initialise them both, how would they express that via configuration properties? In the meantime, you should continue to configure Liquibase manually as you have done in the demo project.

Comment From: wilkinsona

We discussed this today and decided that this isn't something that we want to support. To use Liquibase to initialise a NoSQL database, you should continue to configure it manually.

Comment From: dmitry-weirdo

@wilkinsona ok, but how to configure it manually? I am struggling to find a working example of how to configure Liquibase with MongoDB and Spring Boot.

Should be something like https://github.com/alexandru-slobodcicov/liquibase-nosql-quickstart/tree/main/liquibase-mongodb-quickstart I guess?

Comment From: wilkinsona

Boot can auto-configure a com.mongodb.client.MongoClient for you which I presume Liquibase's Mongo support needs to connect to the Mongo database. Beyond that, I wouldn't expect anything that's Spring Boot-specific so it's probably a question for the Liquibase community.

Comment From: shubha11m

any body have sample how can i connect keyspace to create table with liquibase with springboot with jdbc