Discover how to fix the problem of `Liquibase` not running with Spring Boot's `java -jar` command, ensuring successful database setups with clear solutions and explanations. --- This video is based on the question https://stackoverflow.com/q/69999290/ asked by the user 'Dylan Kidd' ( https://stackoverflow.com/u/4794023/ ) and on the answer https://stackoverflow.com/a/70163744/ provided by the user 'Dylan Kidd' ( https://stackoverflow.com/u/4794023/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions. Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: liquibase does not run with java -jar SpringBoot Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l... The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license. If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com. --- Fixing the Liquibase Issue with Spring Boot JAR Execution Integrating Liquibase into a Spring Boot application is generally straightforward, but developers sometimes run into issues when running their applications as a JAR file. One common problem arises when Liquibase fails to apply changesets during startup after using java -jar app.jar, leading to potential database setup issues. If you've found yourself facing this challenge, you're in the right place! The Problem at Hand When building and running a Spring Boot application packaged as a JAR, you may encounter a situation where Liquibase does not execute its changesets, even though it seems to be running based on the application logs. Here’s a quick look at the situation: You run your application from IntelliJ, and Liquibase updates the database as expected without issues. Upon compiling into a JAR and executing it with java -jar app.jar, you notice that Liquibase only logs actions but does not apply any changesets. This leads to an incomplete database setup, which can cause your application to crash if it expects certain tables or data to be present. Understanding the Solution The solution to this issue can be relatively simple but requires a clear understanding of how file paths work in different runtime contexts. Let’s break it down step by step. Step 1: Identify the Incorrect Path Initially, the Liquibase configuration used a relative path within the changelog file: [[See Video to Reveal this Text or Code Snippet]] This may work successfully when running the application directly in an IDE, but behaves differently when the application is executed from a packaged JAR file. Step 2: Update to an Absolute Path To resolve the issue, the path in the changelog XML should be updated to use an absolute path instead of a relative one: [[See Video to Reveal this Text or Code Snippet]] This change ensures that Liquibase can properly locate the necessary changelog files regardless of how the application is run. Why the Difference? It can be puzzling why the path works in IntelliJ but not when using java -jar. Here are a few potential explanations: Runtime Context: The working directory may differ between the IDE and the command-line execution, affecting relative path resolution. JAR Structure: When packaged, the JAR file may have a different structure that alters how resources are accessed. Using an absolute path circumvents these issues. Best Practices Moving Forward To avoid similar issues in the future, consider the following best practices: Avoid Relative Paths: It's safer to use absolute paths for resource inclusion in Liquibase, ensuring consistent behavior across different execution environments. Test Thoroughly: Always test your application both during development in an IDE and in a production-like setting using JAR execution. Conclusion Solving the Liquibase issue of not applying changesets when running a Spring Boot application as a JAR revolves primarily around understanding and managing file paths effectively. By switching from relative pathing to absolute pathing in your Liquibase changelogs, you can enhance the reliability of your database migrations. If you run into problems or have further questions about your Spring Boot and Liquibase integration, don't hesitate to reach out to the community or seek additional resources!