オブジェクトのバージョン


SpringBootとAWSが単独で実装したWebサービスシリーズは,4ロックを基準に実践した.
本は2019年11月に出版されたが、使用するライブラリやツールの更新速度が速いため、2020年12月に最新バージョンに更新する方法をブログにアップロードした.
そこで、この記事を書いている現在(2021年2月)は、ツールがもっと更新されているかもしれませんが、ブログ記事をベースにバージョン化したいと思います.
最新変更項目の仕様は、ブログで詳しく説明されていますが、変更した部分を簡単に書きたいだけです.

グラデーションバージョンの変更


  • 4.1.02 6.7.1に変更gradlew wrapper --gradle-version 6.7.1

  • build.gradleを変更してgradle 6に適応
  • plugins {
        id 'org.springframework.boot' version '2.4.1'
        id 'io.spring.dependency-management' version '1.0.10.RELEASE'
        id 'java'
    }
    
    group 'com.book'
    version '1.0.1-SNAPSHOT'+ new Date().format("yyyyMMddHHmmss")
    sourceCompatibility = 1.8
    
    repositories {
        mavenCentral()
        jcenter()
    }
    
    test {
        useJUnitPlatform()
    }
    
    
    dependencies {
        implementation('org.springframework.boot:spring-boot-starter-web')
        implementation('org.springframework.boot:spring-boot-starter-mustache')
    
        // lombok
        implementation('org.projectlombok:lombok')
        annotationProcessor('org.projectlombok:lombok')
        testImplementation('org.projectlombok:lombok')
        testAnnotationProcessor('org.projectlombok:lombok')
    
        implementation('org.springframework.boot:spring-boot-starter-data-jpa')
        implementation("org.mariadb.jdbc:mariadb-java-client")
        implementation('com.h2database:h2')
    
        implementation('org.springframework.boot:spring-boot-starter-oauth2-client') // 권한 관련
        implementation('org.springframework.session:spring-session-jdbc') // 권한 관련
    
        testImplementation('org.springframework.boot:spring-boot-starter-test')
        testImplementation("org.springframework.security:spring-security-test") // 권한 관련
    }
  • 修正後勾配テストを行うとJUnitエラーになる
  • JUnitコードの変更

  • ctrl + shift + rすべてのコードをショートカットキーで置き換える
  • @Test

    @RunWith:パッケージの場所と2人のアシスタントが変更されました.


    SpringRunner:パッケージの場所変更と2人のアシスタント


    @After:パッケージの場所、両方のアシスタントが変更され、すべて変更されました


    @Before:パッケージの場所と2人のアシスタントの変更

  • 全て修正とテストを行い、以下のエラーが発生します.
  • JPA


    Spring Boot 2.1.10からMySQL構文の指定方法が変更されたため、データベースの設定を変更する必要があります.src > main > resources > application.properties
    spring.jpa.show_sql=true
    spring.h2.console.enabled=true
    spring.profiles.include=real,oauth
    spring.session.store-type=jdbc
    server.port=8080
    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL57Dialect
    spring.jpa.properties.hibernate.dialect.storage_engine=innodb
    spring.datasource.hikari.jdbc-url=jdbc:h2:mem:testdb;MODE=MYSQL
    spring.datasource.hikari.username=sa
    src > test > resources > application.properties
    spring.jpa.show_sql=true
    spring.h2.console.enabled=true
    spring.session.store-type=jdbc
    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL57Dialect
    spring.jpa.properties.hibernate.dialect.storage_engine=innodb
    spring.datasource.hikari.jdbc-url=jdbc:h2:mem:testdb;MODE=MYSQL
    spring.datasource.hikari.username=sa
  • 修正後、h 2コンソール接続を確保
  • src > main > resources > application-real-db.properties
    spring.jpa.hibernate.ddl-auto=none
    spring.jpa.show_sql=false
    spring.datasource.hikari.jdbc-url=jdbc:mariadb://rds주소:포트명(기본은 3306)/database명
    spring.datasource.hikari.username=db계정
    spring.datasource.hikari.password=db계정 비밀번호
    spring.datasource.hikari.driver-class-name=org.mariadb.jdbc.Driver

    spring.profiles.include

    application.propertiesコード追加
    spring.profiles.group.local-real=local-real, oauth
    spring.profiles.group.real=real, real-db, oauth
    spring.profiles.group.real1=real1, real-db, oauth
    spring.profiles.group.real2=real2, real-db, oauth