Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 可执行JAR无法找到Liquibase db/changelog.xml_Spring Boot - Fatal编程技术网

Spring boot 可执行JAR无法找到Liquibase db/changelog.xml

Spring boot 可执行JAR无法找到Liquibase db/changelog.xml,spring-boot,Spring Boot,项目使用spring boot:run按预期运行。但是,可执行JAR无法运行,因为它找不到db/changelog.xml 以下步骤可用于重现问题: 从项目根目录运行mvn包 转到target文件夹 运行java-jar可执行文件-jar-with-liquibase-1.0.0-SNAPSHOT.jar 日志现在将显示错误,因为尚未创建表domain 请注意,application.yml被找到,因为如果liquibase.enabled被设置为false,它将拒绝完全运行(应该如此) a

项目使用
spring boot:run
按预期运行。但是,可执行JAR无法运行,因为它找不到
db/changelog.xml

以下步骤可用于重现问题:

  • 从项目根目录运行
    mvn包
  • 转到
    target
    文件夹
  • 运行
    java-jar可执行文件-jar-with-liquibase-1.0.0-SNAPSHOT.jar
日志现在将显示错误,因为尚未创建表
domain

请注意,
application.yml
被找到,因为如果
liquibase.enabled
被设置为false,它将拒绝完全运行(应该如此)

application.yml

server:
  context-path: /api
spring:
  datasource:
    platform: h2
    url: jdbc:h2:mem:testdb;MODE=PostgreSQL;DB_CLOSE_ON_EXIT=FALSE
  jackson:
    date-format: yyyy-MM-dd
  jpa:
    database-platform: org.hibernate.dialect.PostgreSQLDialect
    hibernate:
      ddl-auto: none
liquibase:
  enabled: false
  change-log: classpath:db/changelog.xml
生成的JAR包含以下内容:

.
|____BOOT-INF
| |____classes
| | |____application.yml
| | |____db
| | | |____changelog.xml
| | | |____changelogs
| | | | |____changelog_000.xml
| | |____nl
| | | |_____42
| | | | |____app
| | | | | |____ApplicationConfig.class
| | | | | |____domain
| | | | | | |____Domain.class
| | | | | | |____DomainController.class
| | | | | | |____DomainRepository.class
| | | | | | |____DomainService.class
| | | | | |____shared
| | | | | | |____AbstractEntity.class
| | | | | |____WebAppConfig.class
| | | | | |____WebApplication.class
| |____lib
| | |____accessors-smart-1.1.jar
| | |____antlr-2.7.7.jar
| | |____asm-5.0.3.jar
| | |____aspectjweaver-1.8.9.jar
| | |____assertj-core-2.5.0.jar
| | |____classmate-1.3.1.jar
| | |____dom4j-1.6.1.jar
| | |____h2-1.4.192.jar
| | |____hamcrest-core-1.3.jar
| | |____hamcrest-library-1.3.jar
| | |____hibernate-commons-annotations-5.0.1.Final.jar
| | |____hibernate-core-5.0.11.Final.jar
| | |____hibernate-entitymanager-5.0.11.Final.jar
| | |____hibernate-jpa-2.1-api-1.0.0.Final.jar
| | |____hibernate-validator-5.2.4.Final.jar
| | |____jackson-annotations-2.8.3.jar
| | |____jackson-core-2.8.3.jar
| | |____jackson-databind-2.8.3.jar
| | |____jackson-datatype-jsr310-2.8.3.jar
| | |____jandex-2.0.0.Final.jar
| | |____javassist-3.20.0-GA.jar
| | |____javax.transaction-api-1.2.jar
| | |____jboss-logging-3.3.0.Final.jar
| | |____jcl-over-slf4j-1.7.21.jar
| | |____json-20140107.jar
| | |____json-path-2.2.0.jar
| | |____json-smart-2.2.1.jar
| | |____jsonassert-1.3.0.jar
| | |____jul-to-slf4j-1.7.21.jar
| | |____liquibase-core-3.5.1.jar
| | |____log4j-over-slf4j-1.7.21.jar
| | |____logback-classic-1.1.7.jar
| | |____logback-core-1.1.7.jar
| | |____mockito-core-1.10.19.jar
| | |____objenesis-2.1.jar
| | |____slf4j-api-1.7.21.jar
| | |____snakeyaml-1.17.jar
| | |____spring-aop-4.3.3.RELEASE.jar
| | |____spring-aspects-4.3.3.RELEASE.jar
| | |____spring-beans-4.3.3.RELEASE.jar
| | |____spring-boot-1.4.1.RELEASE.jar
| | |____spring-boot-autoconfigure-1.4.1.RELEASE.jar
| | |____spring-boot-configuration-processor-1.4.1.RELEASE.jar
| | |____spring-boot-devtools-1.4.1.RELEASE.jar
| | |____spring-boot-starter-1.4.1.RELEASE.jar
| | |____spring-boot-starter-aop-1.4.1.RELEASE.jar
| | |____spring-boot-starter-data-jpa-1.4.1.RELEASE.jar
| | |____spring-boot-starter-jdbc-1.4.1.RELEASE.jar
| | |____spring-boot-starter-logging-1.4.1.RELEASE.jar
| | |____spring-boot-starter-test-1.4.1.RELEASE.jar
| | |____spring-boot-starter-tomcat-1.4.1.RELEASE.jar
| | |____spring-boot-starter-web-1.4.1.RELEASE.jar
| | |____spring-boot-test-1.4.1.RELEASE.jar
| | |____spring-boot-test-autoconfigure-1.4.1.RELEASE.jar
| | |____spring-context-4.3.3.RELEASE.jar
| | |____spring-core-4.3.3.RELEASE.jar
| | |____spring-data-commons-1.12.3.RELEASE.jar
| | |____spring-data-jpa-1.10.3.RELEASE.jar
| | |____spring-expression-4.3.3.RELEASE.jar
| | |____spring-jdbc-4.3.3.RELEASE.jar
| | |____spring-orm-4.3.3.RELEASE.jar
| | |____spring-tx-4.3.3.RELEASE.jar
| | |____spring-web-4.3.3.RELEASE.jar
| | |____spring-webmvc-4.3.3.RELEASE.jar
| | |____tomcat-embed-core-8.5.5.jar
| | |____tomcat-embed-el-8.5.5.jar
| | |____tomcat-embed-websocket-8.5.5.jar
| | |____tomcat-jdbc-8.5.5.jar
| | |____tomcat-juli-8.5.5.jar
| | |____validation-api-1.1.0.Final.jar
| | |____xml-apis-1.4.01.jar
|____META-INF
| |____MANIFEST.MF
| |____maven
| | |____nl.mad
| | | |____executable-jar-with-liquibase
| | | | |____pom.properties
| | | | |____pom.xml
|____org
| |____springframework
| | |____boot
| | | |____loader
| | | | |____archive
| | | | | |____Archive$Entry.class
| | | | | |____Archive$EntryFilter.class
| | | | | |____Archive.class
| | | | | |____ExplodedArchive$1.class
| | | | | |____ExplodedArchive$FileEntry.class
| | | | | |____ExplodedArchive$FileEntryIterator$EntryComparator.class
| | | | | |____ExplodedArchive$FileEntryIterator.class
| | | | | |____ExplodedArchive.class
| | | | | |____JarFileArchive$EntryIterator.class
| | | | | |____JarFileArchive$JarFileEntry.class
| | | | | |____JarFileArchive.class
| | | | |____data
| | | | | |____ByteArrayRandomAccessData.class
| | | | | |____RandomAccessData$ResourceAccess.class
| | | | | |____RandomAccessData.class
| | | | | |____RandomAccessDataFile$DataInputStream.class
| | | | | |____RandomAccessDataFile$FilePool.class
| | | | | |____RandomAccessDataFile.class
| | | | |____ExecutableArchiveLauncher$1.class
| | | | |____ExecutableArchiveLauncher.class
| | | | |____jar
| | | | | |____AsciiBytes.class
| | | | | |____Bytes.class
| | | | | |____CentralDirectoryEndRecord.class
| | | | | |____CentralDirectoryFileHeader.class
| | | | | |____CentralDirectoryParser.class
| | | | | |____CentralDirectoryVisitor.class
| | | | | |____FileHeader.class
| | | | | |____Handler.class
| | | | | |____JarEntry.class
| | | | | |____JarEntryFilter.class
| | | | | |____JarFile$1.class
| | | | | |____JarFile$2.class
| | | | | |____JarFile$3.class
| | | | | |____JarFile$JarFileType.class
| | | | | |____JarFile.class
| | | | | |____JarFileEntries$1.class
| | | | | |____JarFileEntries$EntryIterator.class
| | | | | |____JarFileEntries.class
| | | | | |____JarURLConnection$1.class
| | | | | |____JarURLConnection$JarEntryName.class
| | | | | |____JarURLConnection.class
| | | | | |____ZipInflaterInputStream.class
| | | | |____JarLauncher.class
| | | | |____LaunchedURLClassLoader$1.class
| | | | |____LaunchedURLClassLoader.class
| | | | |____Launcher.class
| | | | |____MainMethodRunner.class
| | | | |____PropertiesLauncher$1.class
| | | | |____PropertiesLauncher$ArchiveEntryFilter.class
| | | | |____PropertiesLauncher$FilteredArchive$1.class
| | | | |____PropertiesLauncher$FilteredArchive.class
| | | | |____PropertiesLauncher$PrefixMatchingArchiveFilter.class
| | | | |____PropertiesLauncher.class
| | | | |____util
| | | | | |____SystemPropertyUtils.class
| | | | |____WarLauncher.class
整个项目可在此处找到:


我在这里做错了什么?

liquibase中的includeal标签曾经有一个问题。它应该同时修复,但目前我无法使用includeAll标记运行它

为解决您的问题,请使用:

<include file="classpath:db/changelogs/changelog_000.xml" relativeToChangelogFile="false"/>

我也尝试过3.5.2版本,但正如您所说,它似乎不起作用。在Liquibase JIRA杂志上发表评论。