Springboot版本升级-在AWS Elastic beantalk中部署时出现我的SQL错误

时间:2020-10-07 12:24:47

标签: mysql spring-boot amazon-elastic-beanstalk h2 spring-jdbc

我们正在尝试通过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
  • 从版本1.5.72.3.3的spring-boot
  • 从版本Gradle-4.8-all升级到Gradle-6.4.1-all

在本地进行乘法运算时,我们在日志中得到以下输出,

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版本错误的原因?

1 个答案:

答案 0 :(得分:0)

问题:

Run文件的

jar命令是此项目的问题`

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

解决方案:

我已尝试对run文件使用此run命令,而不是上面的jar命令

  Dspring.config.additional-location=run.properties

这很好用