Spring Boot バージョンアップ(2.2 to 2.3)

## Spring Bootのバージョンアップ 2.2 to 2.3 のメモ

バージョンアップをずっと放置していたのでぼちぼちやっていこうと思い、そのメモです。

現在の環境
Spring Boot:2.2
Gradle:6.0.1
Kotlin:1.4

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#validation-starter-no-longer-included-in-web-starters


# 1.　まずはbuild.gradle.ktsのspinrg bootのバージョンを修正
```kotlin:build.gradle.kts
plugins {
//	id("org.springframework.boot") version "2.2.2.RELEASE"
	id("org.springframework.boot") version "2.3.12.RELEASE"
	kotlin("jvm") version "1.4.10"
}
```

# 2.　ここからはビルドをひたすらやりながらエラーを潰していきます

## :innocent:　gradleのバージョンで怒られる
```terminal:terminal
$ ./gradlew build                                        

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/yukiyoshimura/dev/awba/awba-management/build.gradle.kts' line: 4

* What went wrong:
An exception occurred applying plugin request [id: 'org.springframework.boot', version: '2.3.12.RELEASE']
> Failed to apply plugin [id 'org.springframework.boot']
   > Spring Boot plugin requires Gradle 5 (5.6.x only) or Gradle 6 (6.3 or later). The current version is Gradle 6.0.1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
```

### 対応　gradle-wrapper.propertiesにあるgradleのバージョンを6.3以降にする
```properties:gradle-wrapper.properties
# distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
  distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
```

## :innocent:　developmentOnlyのところで怒られる

```terminal:terminal
$ ./gradlew build
Downloading https://services.gradle.org/distributions/gradle-6.3-bin.zip
.................................................................................................

Welcome to Gradle 6.3!


Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :
e: /Users/yukiyoshimura/dev/awba/awba-management/build.gradle.kts:30:15: Type mismatch: inferred type is NamedDomainObjectProvider<Configuration> but Configuration! was expected

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/yukiyoshimura/dev/awba/awba-management/build.gradle.kts' line: 30

* What went wrong:
Script compilation error:

  Line 30:              extendsFrom(developmentOnly)
                         ^ Type mismatch: inferred type is NamedDomainObjectProvider<Configuration> but Configuration! was expected

1 error

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 42s
~/dev/awba/awba-management (develop *=)
```
## 対応　build.gradle.ktsのspinrg bootのdevelopmentOnlyの定義は不要になっているので消す

以下コメントアウトしている箇所が削除対象
```gradle:build.gradle.kts
//val developmentOnly by configurations.creating
configurations {
//	runtimeClasspath {
//		extendsFrom(developmentOnly)
//	}
}

// 上記を消すだけでちゃんとdependncies内では developmentOnlyが使える
dependencies {
	developmentOnly("org.springframework.boot:spring-boot-devtools")
}
```
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#automatic-creation-of-developmentonly-gradle-configuration

## :innocent:　Unresolved reference: validation で怒られる

### 対応　build.gradle.ktsのdependenciesに以下を追加


```gradle:build.gradle.kts
dependencies {
    implementation("org.springframework.boot:spring-boot-starter-validation")
}
```

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#validation-starter-no-longer-included-in-web-starters

## :innocent: テスト実施時にprofileの読み込みでエラー

以下のような宣言をしていると

```kotlin:test.kt
@SpringBootTest
@ActiveProfiles("test")
class Test {
}
```
エラーになった
```terminal:terminal
IllegalArgumentException: Could not resolve placeholder 'spring.profiles.active' in value "${spring.profiles.active}"
```

### 対応
```kotlin:test.kt
@SpringBootTest("spring.profiles.active:test")
class Test{
}
```
https://github.com/spring-projects/spring-boot/issues/19788

以上です。ちょっとずつバージョン上げていこうと思います。