mike-neckのブログ

Java or Groovy or Swift or Golang

Functional Spring Hands On に行ってきた

表題の通り、 Functional Spring Hands On に行ってきた。

pivotal-japan.connpass.com

ハンズオンの資料はこれ

github.com

基本的に手を動かさないと理解が遅いので、わりとハンズオンは好きです(用意する方は大変)

内容は、 Spring(WebFlux) アプリケーションを @SpringBootApplication なしで記述するというもの。さらに R2DBC もついてた。

R2DBC はまだ開発が進んでいる最中で、以前のエントリーは完全に無意味になってた…


ハンズオンは maven ベースで行われていたが、 gradle でやった。そのために、途中で依存ライブラリーがわからなくなり、ついていけなくなってしまった…

なお、この build.gradle なら、ハンズオンの内容を実施できる(成果)

plugins {
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
    maven {
        url = new URL('https://repo.spring.io/snapshot')
    }
    maven {
        url = new URL('https://repo.spring.io/milestone')
    }
    maven {
        url = new URL('https://jitpack.io')
    }
}

dependencies {
    implementation platform('org.springframework.boot:spring-boot-dependencies:2.2.0.M3')
    implementation platform('io.r2dbc:r2dbc-bom:Arabba-M8')

    implementation "com.github.making:moneyger-ui:master-SNAPSHOT"

    implementation "org.springframework:spring-context"
    implementation "org.springframework:spring-webflux"
    implementation "org.springframework:spring-tx"
    implementation "ch.qos.logback:logback-classic"
    implementation "io.projectreactor.netty:reactor-netty"
    implementation "com.fasterxml.jackson.core:jackson-databind"
    implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"

    implementation 'io.r2dbc:r2dbc-pool'

    implementation 'org.springframework.data:spring-data-r2dbc:1.0.0.M2'
    testRuntimeOnly 'io.r2dbc:r2dbc-h2'
    runtimeOnly 'io.r2dbc:r2dbc-postgresql'

    implementation 'am.ik.yavi:yavi:0.2.2'

    testImplementation ('org.springframework.boot:spring-boot-starter-test') {
        exclude module: 'junit'
    }
    testImplementation 'io.projectreactor:reactor-test'
    testImplementation 'org.junit.jupiter:junit-jupiter'

    testImplementation 'org.assertj:assertj-core'
}