Spring Boot 版本升级 - 在 aws elastic beanstalk 中部署时出现 sql 错误

Springboot version upgrade - my sql error while deploying in aws elastic beanstalk

我们正在尝试通过 build.gradle 依赖项升级我们的项目:

build.gradle 文件:

buildscript {
    ext {
        springBootVersion = '2.3.3.RELEASE'
    }
    repositories {
        mavenCentral()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath('se.transmode.gradle:gradle-docker:1.2')
    }
}

group = 'testing'
version = '0.0.1-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: "jacoco"
apply from: 'docker.gradle'

sourceCompatibility = 1.8

bootJar {
    launchScript()
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    compile ('org.springframework.boot:spring-boot-starter-data-jpa')
    compile ('org.springframework.boot:spring-boot-starter-web')
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.flywaydb:flyway-core'
    runtime 'mysql:mysql-connector-java:5.1.47'
    implementation 'com.zaxxer:HikariCP'
    annotationProcessor('org.hibernate:hibernate-jpamodelgen')
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.mobile:spring-mobile-device:1.1.5.RELEASE'
    implementation 'io.jsonwebtoken:jjwt-api:0.10.5'
    runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.10.5'
    runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.10.5'
    implementation 'com.amazonaws:aws-java-sdk-s3:1.11.136'
    implementation 'org.springframework.boot:spring-boot-starter-mail'
    implementation 'org.springframework.boot:spring-boot-starter-freemarker'
    implementation 'org.springframework.boot:spring-boot-starter-tomcat'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    testCompile('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    testImplementation('org.springframework.security:spring-security-test')
    compile 'com.h2database:h2'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    implementation 'org.apache.commons:commons-lang3'
    implementation 'com.univocity:univocity-parsers:2.7.6'
    implementation 'org.quartz-scheduler:quartz:2.2.1'
    implementation 'org.apache.poi:poi:3.17'
    implementation 'org.apache.poi:poi-ooxml:3.17'
}



test.reports.junitXml.setDestination(file("${buildDir}/test-results"))

jacocoTestReport {
    reports {
        html.destination file("${buildDir}/jacocoHtml")
    }
}

sourceSets {
    main {
        java {
            srcDirs += "src/jpaModelgen/java"
        }
    }
}


compileJava {
    options.compilerArgs += ['-AaddGenerationDate=true'] // Specific to Hibernate JPA meta model generation processor.
    options.annotationProcessorGeneratedSourcesDirectory = file("src/jpaModelgen/java")
}

application.properties 文件:

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.database=mysql
spring.data.jpa.repositories.enabled=true
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

spring.datasource.url= jdbc:mysql://MyDB:3306/myschema
spring.datasource.username= testing
spring.datasource.password= root

当我们在本地 运行 应用程序时,我们在日志中得到以下输出,

o.f.c.internal.database.DatabaseFactory  : Database: jdbc:mysql://MyDB:3306/myschema (MySQL 5.7)

当我们将相同的代码部署到 AWS Elastic Beanstalk 时, 我们收到以下错误:

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$FlywayMigrateException: 
    Migration V3__Sequence_Table.sql failed
    ---------------------------------------
    SQL State  : 42001
    Error Code : 42001
    Message    : Syntax error in SQL statement "DELIMITER[*]  

JDBC 连接 URL 现在已更改如下,

o.f.c.internal.database.DatabaseFactory  : Database: jdbc:h2:mem:testdb (H2 1.4)

这是导致上述flyway迁移错误还是Docker版本错误的原因?

问题:

Run jar 文件的命令是这个项目的问题`

Dspring.config.location=run.properties 这个命令只执行 run.properties

解决方法:

代替上面的 run 命令,我已经为 jar 文件尝试了这个 run 命令

  Dspring.config.additional-location=run.properties

效果很好