自升级到Spring Boot v2以来,h2Database上的迁移方式迁移时出错

时间:2018-07-19 12:48:19

标签: spring-boot h2 flyway spring-boot-test

我正在寻找解决方案,但没有发现任何东西。我有一个通过飞行路线进行迁移的服务。作为此服务集成测试的一部分,我们使用h2数据库。以前,所有测试和迁移都基于Spring Boot 1.5.9.RELEASE

版本,在h2数据库上有效。

自从升级到2.0.3.RELEASE之后,当我运行本地MySQL数据库时,迁移仍然可以正常进行,但是当我在h2database上运行测试时却无法正常工作。

请注意,我无法编辑脚本,并且我仍想在测试中运行flyway(如果可以的话,解决方案将很容易)。我想修复我的测试,使其按目前的状态执行。

有问题的迁移脚本。该错误是由于RENAME表语法似乎是由于h2db不支持该格式的语法。但是,这看上去确实像以前一样受支持(否则这些测试将在1.5.9.RELEASE上失败)

ALTER TABLE `keys` CHANGE `key_value` `content_key` varchar(255) NOT NULL;

DROP INDEX `key_value_idx` on `keys`;
CREATE INDEX `content_key_idx` on `keys` (`content_key`);

RENAME TABLE `keys` TO `content_keys`;

错误

java.lang.IllegalStateException: Failed to load ApplicationContext

at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:44)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at com.github.tomakehurst.wiremock.junit.WireMockClassRule$1.evaluate(WireMockClassRule.java:70)
at com.github.tomakehurst.wiremock.junit.WireMockClassRule$1.evaluate(WireMockClassRule.java:70)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateSqlException: 
Migration V2__rename_key_val.sql failed
---------------------------------------
SQL State  : 42001
Error Code : 42001
Message    : Syntax error in SQL statement "RENAME[*] TABLE ""KEYS"" TO ""CONTENT_KEYS"" "; expected "ROLLBACK, REVOKE, RUNSCRIPT, RELEASE, REPLACE, {"; SQL statement:
RENAME TABLE `keys` TO `content_keys` [42001-197]
Location   : db/migration/V2__rename_key_val.sql (/Users/ciaran.potter/Workspace/foobar/target/classes/db/migration/V2__rename_key_val.sql)
Line       : 7
Statement  : RENAME TABLE `keys` TO `content_keys`
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1708)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1089)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:859)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:139)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
... 38 more
Caused by: org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateSqlException:
Migration V2__rename_key_val.sql failed
---------------------------------------
SQL State  : 42001
Error Code : 42001
Message    : Syntax error in SQL statement "RENAME[*] TABLE ""KEYS"" TO ""CONTENT_KEYS"" "; expected "ROLLBACK, REVOKE, RUNSCRIPT, RELEASE, REPLACE, {"; SQL statement:
RENAME TABLE `keys` TO `content_keys` [42001-197]
Location   : db/migration/V2__rename_key_val.sql (/Users/ciaran.potter/Workspace/foobar/target/classes/db/migration/V2__rename_key_val.sql)
Line       : 7
Statement  : RENAME TABLE `keys` TO `content_keys`

at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:365)
at org.flywaydb.core.internal.command.DbMigrate.access$400(DbMigrate.java:52)
at org.flywaydb.core.internal.command.DbMigrate$5.call(DbMigrate.java:297)
at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:75)
at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:294)
at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:259)
at org.flywaydb.core.internal.command.DbMigrate.access$300(DbMigrate.java:52)
at org.flywaydb.core.internal.command.DbMigrate$4.call(DbMigrate.java:179)
at org.flywaydb.core.internal.command.DbMigrate$4.call(DbMigrate.java:176)
at org.flywaydb.core.internal.database.Connection$1.call(Connection.java:155)
at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:75)
at org.flywaydb.core.internal.database.Connection.lock(Connection.java:151)
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:148)
at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:176)
at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:145)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:1206)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:1168)
at org.flywaydb.core.Flyway.execute(Flyway.java:1655)
at org.flywaydb.core.Flyway.migrate(Flyway.java:1168)
at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1767)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1704)
... 56 more
Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "RENAME[*] TABLE ""KEYS"" TO ""CONTENT_KEYS"" "; expected "ROLLBACK, REVOKE, RUNSCRIPT, RELEASE, REPLACE, {"; SQL statement:
RENAME TABLE `keys` TO `content_keys` [42001-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
at org.h2.message.DbException.getSyntaxError(DbException.java:217)
at org.h2.command.Parser.getSyntaxError(Parser.java:555)
at org.h2.command.Parser.parsePrepared(Parser.java:540)
at org.h2.command.Parser.parse(Parser.java:335)
at org.h2.command.Parser.parse(Parser.java:311)
at org.h2.command.Parser.prepareCommand(Parser.java:278)
at org.h2.engine.Session.prepareLocal(Session.java:611)
at org.h2.engine.Session.prepareCommand(Session.java:549)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1247)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:217)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:205)
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95)
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
at org.flywaydb.core.internal.util.jdbc.JdbcTemplate.executeStatement(JdbcTemplate.java:265)
at org.flywaydb.core.internal.database.StandardSqlStatement.execute(StandardSqlStatement.java:41)
at org.flywaydb.core.internal.database.ExecutableSqlScript.execute(ExecutableSqlScript.java:128)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:75)
at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:363)
... 77 more

mvn dependency:list -Dsort的结果

[INFO] Scanning for projects...
[INFO] 
[INFO] Building FooBar 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The artifact org.hibernate:hibernate-validator:jar:6.0.8.Final has been relocated to org.hibernate.validator:hibernate-validator:jar:6.0.8.Final
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ foobar ---
[INFO] 
[INFO] The following files have been resolved:
[INFO]    antlr:antlr:jar:2.7.7:compile
[INFO]    ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO]    ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO]    com.fasterxml.jackson.core:jackson-annotations:jar:2.9.5:compile
[INFO]    com.fasterxml.jackson.core:jackson-core:jar:2.9.6:compile
[INFO]    com.fasterxml.jackson.core:jackson-databind:jar:2.9.5:compile
[INFO]    com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.9.5:compile
[INFO]    com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.6:compile
[INFO]    com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.5:compile
[INFO]    com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.9.6:compile
[INFO]    com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.9.5:compile
[INFO]    com.fasterxml.jackson.module:jackson-module-afterburner:jar:2.9.6:runtime
[INFO]    com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.9.6:compile
[INFO]    com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.6:compile
[INFO]    com.fasterxml:classmate:jar:1.3.4:compile
[INFO]    com.github.tomakehurst:wiremock-standalone:jar:2.17.0:test
[INFO]    com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO]    com.google.errorprone:error_prone_annotations:jar:2.1.3:compile
[INFO]    com.google.guava:guava:jar:24.1-jre:compile
[INFO]    com.google.j2objc:j2objc-annotations:jar:1.1:compile
[INFO]    com.google.protobuf:protobuf-java:jar:2.6.0:runtime
[INFO]    com.h2database:h2:jar:1.4.197:runtime
[INFO]    com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO]    com.netflix.archaius:archaius-core:jar:0.7.6:compile
[INFO]    com.netflix.hystrix:hystrix-core:jar:1.5.12:compile
[INFO]    com.netflix.hystrix:hystrix-javanica:jar:1.5.12:compile
[INFO]    com.netflix.hystrix:hystrix-metrics-event-stream:jar:1.5.12:compile
[INFO]    com.netflix.hystrix:hystrix-serialization:jar:1.5.12:compile
[INFO]    com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO]    com.zaxxer:HikariCP:jar:2.7.9:compile
[INFO]    commons-codec:commons-codec:jar:1.11:compile
[INFO]    commons-configuration:commons-configuration:jar:1.8:compile
[INFO]    commons-io:commons-io:jar:2.5:compile
[INFO]    commons-lang:commons-lang:jar:2.6:compile
[INFO]    commons-logging:commons-logging:jar:1.2:compile
[INFO]    dom4j:dom4j:jar:1.6.1:compile
[INFO]    io.micrometer:micrometer-core:jar:1.0.5:compile
[INFO]    io.reactivex:rxjava-reactive-streams:jar:1.2.1:compile
[INFO]    io.reactivex:rxjava:jar:1.3.8:compile
[INFO]    io.sentry:sentry-logback:jar:1.7.5:runtime
[INFO]    io.sentry:sentry:jar:1.7.5:runtime
[INFO]    io.springfox:springfox-core:jar:2.8.0:compile
[INFO]    io.springfox:springfox-schema:jar:2.8.0:compile
[INFO]    io.springfox:springfox-spi:jar:2.8.0:compile
[INFO]    io.springfox:springfox-spring-web:jar:2.8.0:compile
[INFO]    io.springfox:springfox-swagger-common:jar:2.8.0:compile
[INFO]    io.springfox:springfox-swagger-ui:jar:2.8.0:compile
[INFO]    io.springfox:springfox-swagger2:jar:2.8.0:compile
[INFO]    io.swagger:swagger-annotations:jar:1.5.14:compile
[INFO]    io.swagger:swagger-models:jar:1.5.14:compile
[INFO]    javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO]    javax.inject:javax.inject:jar:1:compile
[INFO]    javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO]    javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO]    javax.ws.rs:javax.ws.rs-api:jar:2.1:compile
[INFO]    junit:junit:jar:4.12:test
[INFO]    mysql:mysql-connector-java:jar:8.0.11:compile
[INFO]    net.bytebuddy:byte-buddy-agent:jar:1.7.11:test
[INFO]    net.bytebuddy:byte-buddy:jar:1.7.11:compile
[INFO]    net.logstash.logback:logstash-logback-encoder:jar:5.1:compile
[INFO]    net.minidev:accessors-smart:jar:1.2:test
[INFO]    net.minidev:json-smart:jar:2.3:test
[INFO]    org.apache.commons:commons-csv:jar:1.4:compile
[INFO]    org.apache.commons:commons-lang3:jar:3.7:compile
[INFO]    org.apache.httpcomponents:fluent-hc:jar:4.5.5:compile
[INFO]    org.apache.httpcomponents:httpclient:jar:4.5.5:compile
[INFO]    org.apache.httpcomponents:httpcore:jar:4.4.9:compile
[INFO]    org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO]    org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO]    org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.31:compile
[INFO]    org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.31:compile
[INFO]    org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.31:compile
[INFO]    org.aspectj:aspectjweaver:jar:1.8.13:compile
[INFO]    org.assertj:assertj-core:jar:3.9.1:test
[INFO]    org.attoparser:attoparser:jar:2.0.4.RELEASE:compile
[INFO]    org.bouncycastle:bcpkix-jdk15on:jar:1.56:compile
[INFO]    org.bouncycastle:bcprov-jdk15on:jar:1.56:compile
[INFO]    org.checkerframework:checker-compat-qual:jar:2.0.0:compile
[INFO]    org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile
[INFO]    org.eclipse.jetty:jetty-client:jar:9.4.11.v20180605:compile
[INFO]    org.eclipse.jetty:jetty-http:jar:9.4.11.v20180605:compile
[INFO]    org.eclipse.jetty:jetty-io:jar:9.4.11.v20180605:compile
[INFO]    org.eclipse.jetty:jetty-util:jar:9.4.11.v20180605:compile
[INFO]    org.flywaydb:flyway-core:jar:5.0.7:compile
[INFO]    org.glassfish.hk2.external:aopalliance-repackaged:jar:2.5.0-b42:compile
[INFO]    org.glassfish.hk2.external:javax.inject:jar:2.5.0-b42:compile
[INFO]    org.glassfish.hk2:hk2-api:jar:2.5.0-b42:compile
[INFO]    org.glassfish.hk2:hk2-locator:jar:2.5.0-b42:compile
[INFO]    org.glassfish.hk2:hk2-utils:jar:2.5.0-b42:compile
[INFO]    org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
[INFO]    org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.26-b03:compile
[INFO]    org.glassfish.jersey.connectors:jersey-apache-connector:jar:2.27:test
[INFO]    org.glassfish.jersey.connectors:jersey-jetty-connector:jar:2.27:compile
[INFO]    org.glassfish.jersey.core:jersey-client:jar:2.27:compile
[INFO]    org.glassfish.jersey.core:jersey-common:jar:2.26:compile
[INFO]    org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.26:compile
[INFO]    org.glassfish.jersey.inject:jersey-hk2:jar:2.27:compile
[INFO]    org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.27:compile
[INFO]    org.hamcrest:hamcrest-core:jar:1.3:test
[INFO]    org.hamcrest:hamcrest-library:jar:1.3:test
[INFO]    org.hdrhistogram:HdrHistogram:jar:2.1.10:compile
[INFO]    org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO]    org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.2.Final:compile
[INFO]    org.hibernate.validator:hibernate-validator:jar:6.0.8.Final:compile
[INFO]    org.hibernate:hibernate-core:jar:5.2.17.Final:compile
[INFO]    org.hibernate:hibernate-entitymanager:jar:5.2.17.Final:compile
[INFO]    org.hibernate:hibernate-java8:jar:5.2.17.Final:compile
[INFO]    org.javassist:javassist:jar:3.22.0-GA:compile
[INFO]    org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO]    org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.1.Final:compile
[INFO]    org.jboss:jandex:jar:2.0.3.Final:compile
[INFO]    org.latencyutils:LatencyUtils:jar:2.0.3:compile
[INFO]    org.mapstruct:mapstruct:jar:1.2.0.Final:compile
[INFO]    org.mockito:mockito-core:jar:2.19.0:test
[INFO]    org.objenesis:objenesis:jar:2.6:test
[INFO]    org.ow2.asm:asm:jar:5.0.4:runtime
[INFO]    org.projectlombok:lombok:jar:1.16.18:compile
[INFO]    org.reactivestreams:reactive-streams:jar:1.0.2:runtime
[INFO]    org.reflections:reflections:jar:0.9.11:compile
[INFO]    org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO]    org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO]    org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO]    org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-actuator:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-autoconfigure:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-actuator:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-aop:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-cache:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-data-jpa:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-jdbc:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-json:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-logging:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-security:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-test:jar:2.0.3.RELEASE:test
[INFO]    org.springframework.boot:spring-boot-starter-thymeleaf:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-web:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.3.RELEASE:test
[INFO]    org.springframework.boot:spring-boot-test:jar:2.0.3.RELEASE:test
[INFO]    org.springframework.boot:spring-boot:jar:2.0.3.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-commons:jar:2.0.0.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-context:jar:2.0.0.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-netflix-archaius:jar:2.0.0.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-netflix-core:jar:2.0.0.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-netflix-ribbon:jar:2.0.0.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-starter-hystrix:jar:1.4.4.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-starter-netflix-archaius:jar:2.0.0.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-starter-netflix-hystrix:jar:2.0.0.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-starter:jar:2.0.0.RELEASE:compile
[INFO]    org.springframework.data:spring-data-commons:jar:2.0.8.RELEASE:compile
[INFO]    org.springframework.data:spring-data-jpa:jar:2.0.8.RELEASE:compile
[INFO]    org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO]    org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO]    org.springframework.security:spring-security-config:jar:5.0.6.RELEASE:compile
[INFO]    org.springframework.security:spring-security-core:jar:5.0.6.RELEASE:compile
[INFO]    org.springframework.security:spring-security-crypto:jar:5.0.6.RELEASE:compile
[INFO]    org.springframework.security:spring-security-rsa:jar:1.0.5.RELEASE:compile
[INFO]    org.springframework.security:spring-security-web:jar:5.0.6.RELEASE:compile
[INFO]    org.springframework:spring-aop:jar:5.0.7.RELEASE:compile
[INFO]    org.springframework:spring-aspects:jar:5.0.7.RELEASE:compile
[INFO]    org.springframework:spring-beans:jar:5.0.7.RELEASE:compile
[INFO]    org.springframework:spring-context-support:jar:5.0.7.RELEASE:compile
[INFO]    org.springframework:spring-context:jar:5.0.7.RELEASE:compile
[INFO]    org.springframework:spring-core:jar:5.0.7.RELEASE:compile
[INFO]    org.springframework:spring-expression:jar:5.0.7.RELEASE:compile
[INFO]    org.springframework:spring-jcl:jar:5.0.7.RELEASE:compile
[INFO]    org.springframework:spring-jdbc:jar:5.0.7.RELEASE:compile
[INFO]    org.springframework:spring-orm:jar:5.0.7.RELEASE:compile
[INFO]    org.springframework:spring-test:jar:5.0.7.RELEASE:test
[INFO]    org.springframework:spring-tx:jar:5.0.7.RELEASE:compile
[INFO]    org.springframework:spring-web:jar:5.0.7.RELEASE:compile
[INFO]    org.springframework:spring-webmvc:jar:5.0.7.RELEASE:compile
[INFO]    org.thymeleaf.extras:thymeleaf-extras-java8time:jar:3.0.1.RELEASE:compile
[INFO]    org.thymeleaf:thymeleaf-spring5:jar:3.0.9.RELEASE:compile
[INFO]    org.thymeleaf:thymeleaf:jar:3.0.9.RELEASE:compile
[INFO]    org.unbescape:unbescape:jar:1.1.5.RELEASE:compile
[INFO]    org.xmlunit:xmlunit-core:jar:2.5.1:test
[INFO]    org.yaml:snakeyaml:jar:1.19:runtime

我的测试应用程序。yaml

server.port: 18091
pathPrefix: ''

management:
      health:
        diskspace:
          enabled: true

endpoints:
  enabled: true
  health:
    enabled: true
    sensitive: false

spring.jackson.mapper.use_static_typing: true

consumerWhitelist: test,test1

server.compression.enabled: true
server.compression.mime-types: application/json,application/xml,text/html,text/xml,text/plain
logging:
  level:
    ROOT: INFO
    org.springframework: INFO
    org.hibernate: INFO
    liquibase: INFO
    springfox: INFO
    org.apache: WARN
    org.apache.http.wire: INFO
    org.slf4j.logger.org.apache.http: WARN
    org.thymeleaf: WARN
    com.netflix.hystrix: INFO
    javax: INFO

spring:
  datasource:
    driverClassName: org.h2.Driver
    url: jdbc:h2:mem:foobar;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=TRUE;MODE=MYSQL
    username: foobar
    password: password

1 个答案:

答案 0 :(得分:0)

替换

RENAME TABLE 'table1' TO 'table2';

使用

ALTER TABLE 'table1' RENAME TO 'table2';