簡體   English   中英

springboot 版本升級 - 我在 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")
}

應用程序.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
  • spring-boot 從版本1.5.72.3.3
  • Gradle 從版本Gradle-4.8-allGradle-6.4.1-all

當我們在本地運行應用程序時,我們在日志中得到以下 output,

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版本錯誤的原因?

問題:

jar文件的Run命令是這個項目的問題`

Dspring.config.location=run.properties這個命令只執行run.properties

解決方案:

而不是上面的run命令,我已經為jar文件嘗試了這個run命令

  Dspring.config.additional-location=run.properties

這很好用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM