我在内存数据库中用h2创建了一个spring boot rest项目。我定义了一些实体,并使用liquibase maven插件target-diff从我的实体生成变更日志。运行目标时,我从liquibase收到Nullpointer异常并显示一条信息消息-获取默认架构时出错
我正在使用Spring Boot版本2,hibernate 5和liquibase版本3.6.3。 liquibase插件版本尝试了3.6和3.7
我的配置如下
pom依赖
<!-- Jpa dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Liquibase dependencies -->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibase-version}</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase-version}</version>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>3.7</version>
</dependency>
application.properties
springfox.documentation.swagger.v2.path=/api-docs
server.servlet.context-path=/tmf-api/troubleTicket
server.port=8181
spring.jackson.date-format=org.tmf.openapi.troubleticket.RFC3339DateFormat
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
spring.datasource.platform=h2
spring.datasource.url=jdbc:h2:mem:troubleticket;DB_CLOSE_DELAY=-1
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=troubleticket
spring.datasource.password=tmftt
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true
spring.h2.console.path=/troubleticketdb-console
spring.h2.console.settings.trace=false
spring.h2.console.settings.web-allow-others=false
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.liquibase.enabled=true
spring.liquibase.url=jdbc:h2:mem:troubleticket;DB_CLOSE_DELAY=-1
spring.liquibase.user=troubleticket
spring.liquibase.password=tmftt
spring.liquibase.change-log=classpath:db/liquibase/db-changelog-master.xml
spring.liquibase.default-schema=public
liquibase.properties
changeLogFile=classpath:db/liquibase/db-changelog-master.xml
url=jdbc:h2:mem:troubleticket;DB_CLOSE_DELAY=-1
username=troubleticket
password=tmftt
driver=org.h2.Driver
referenceUrl=hibernate:spring:org.tmf.openapi.troubleticket.persistence.model?dialect=org.hibernate.dialect.H2Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
referenceUsername=troubleticket
referencePassword=tmftt
diffChangeLogFile=src/main/resources/db/liquibase/liquibase-diff-changeLog.xml
outputChangeLogFile=src/main/resources/db/liquibase/liquibase-gen-changeLog.xml
以下是我遇到的错误
--- liquibase-maven-plugin:3.6.3:diff (default-cli) @ troubleticket-api ---
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO] File: src/main/resources/db/liquibase/liquibase.properties
[INFO] 'outputChangeLogFile' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Starting Liquibase at Fri, 12 Jul 2019 12:59:12 IST (version 3.6.3 built at 2019-01-29 11:34:48)
[INFO] Executing on Database: jdbc:h2:mem:troubleticket;DB_CLOSE_DELAY=-1
[WARNING] Unknown database: Hibernate
[INFO] Performing Diff on database TROUBLETICKET @ jdbc:h2:mem:troubleticket (Default Schema: PUBLIC)
[INFO] Error getting default schema
java.lang.NullPointerException
at liquibase.executor.jvm.JdbcExecutor$QueryCallableStatementCallback.doInCallableStatement(JdbcExecutor.java:452)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:93)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:135)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:146)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:154)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:169)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:164)
at liquibase.database.AbstractJdbcDatabase.getConnectionSchemaName(AbstractJdbcDatabase.java:327)
at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:292)
at liquibase.CatalogAndSchema.customize(CatalogAndSchema.java:151)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:184)
at liquibase.command.core.DiffCommand.createReferenceSnapshot(DiffCommand.java:221)
at liquibase.command.core.DiffCommand.createDiffResult(DiffCommand.java:143)
at liquibase.command.core.DiffToChangeLogCommand.run(DiffToChangeLogCommand.java:51)
at liquibase.command.AbstractCommand.execute(AbstractCommand.java:19)
at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:237)
at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:212)
at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.performLiquibaseTask(LiquibaseDatabaseDiff.java:177)
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:366)
at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.execute(LiquibaseDatabaseDiff.java:136)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)