1

I am developing a custom spring-boot-starter that can be included in any project. For it work it need to create a couple of tables in the database in the main application. For this I use liquibase migrations which are described in the spring-boot-starter module. Also in the starter in the application.properties file I describe the properties

spring.datasource.url=jdbc:postgresql://localhost:5432/message

spring.liquibase.change-log=classpath:liquibase/changelog.xml

When starting the main application, which contains my starter in dependencies, I get an exception:

Description:

Liquibase failed to start because no changelog could be found at 'classpath:/db/changelog/db.changelog-master.yaml'.

Action:

Make sure a Liquibase changelog is present at the configured path.

The application looks for a path to migrations and migrations inside the project, but does not look for them inside the starter scope.

Please tell me what needs to be done so that when the application starts, the migrations described in the starter are also pulled up?

How to set up liquibase? Or maybe there is some other way to run sql scripts if the required tables are missing?

  • You need to find a way for the project that you want to copy the starter resources to yours. This is usually done by packaging the resources with something like the maven archive plugin (so they can be exported to nexus), then using classifiers to get such archives and import them again via maven plugins. – ruifn Dec 08 '22 at 20:28
  • 1. i never saw/who cares about `application.properties` of starters... (they are only for test/and should not be packaged;) 2. Your app seems to use "spring-boot-default": `classpath:/db/changelog/db.changelog-master.yaml` (which it fails to find...set it *in your application*: `spring.liquibase.change-log=classpath:liquibase/changelog.xml`, works... – xerx593 Dec 08 '22 at 21:13
  • in depth: https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.developing-auto-configuration, articles: https://medium.com/javarevisited/how-to-build-a-custom-spring-boot-starter-1643fc33a903, https://www.baeldung.com/spring-boot-custom-starter , also relevant: https://spring.io/guides/gs/multi-module/ – xerx593 Dec 08 '22 at 21:19

0 Answers0