使用 Spring 应用程序将 Liquibase 嵌入到 jar 中

Embedding Liquibase in a jar with Spring Application

我在尝试使用 liquibase 在 uberjar 中嵌入纯 Spring(不是 Spring 启动)应用程序时遇到了一个非常具体的错误。 SpringLiquibase bean 一初始化,它就开始寻找我不明白的东西:

WARNING 7/16/15 3:22 PM: liquibase: No Liquibase-Packages entry found in MANIFEST.MF. Using fallback of entire 'liquibase' package
WARNING 7/16/15 3:28 PM: liquibase: Error initializing SpringLiquibase
java.io.FileNotFoundException: ServletContext resource [/liquibase] cannot be resolved to URL because it does not exist
at org.springframework.web.context.support.ServletContextResource.getURL(ServletContextResource.java:156)
at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.init(SpringLiquibase.java:117)
at liquibase.resource.AbstractResourceAccessor.<init>(AbstractResourceAccessor.java:22)
at liquibase.resource.ClassLoaderResourceAccessor.<init>(ClassLoaderResourceAccessor.java:19)
at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.<init>(SpringLiquibase.java:74)
at liquibase.integration.spring.SpringLiquibase.createResourceOpener(SpringLiquibase.java:489)
at liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:439)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:389)
WARNING 7/16/15 3:28 PM: liquibase: Error initializing SpringLiquibase
java.io.FileNotFoundException: ServletContext resource [/liquibase] cannot be resolved to URL because it does not exist
(stacktrace again)

我知道 MANIFEST.MF 中的 Liquibase-Package 条目并使用 shade 插件填充它(虽然我不明白它有什么用)并使用 shade 插件放置它,但它没有'没有任何效果。 liquibase 在寻找什么,我该如何克服这些错误?

根据此 issue,如果您创建 src/main/webapp 文件夹,此问题将得到解决:

Incidentally, the root cause is that no src/main/webapp folder exists. As a work around you could create one or set a value in @WebAppConfiguration that points to classpath: folder that actually exists.