Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SpringBootとKotlinでサクッと作るWebサービス
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
YUMOTO Michitaka
December 05, 2017
Technology
0
1.1k
SpringBootとKotlinでサクッと作るWebサービス
DocurainのWeb-API部分の実装やバックエンドについての資料です。
https://quality-start.in/docurain
YUMOTO Michitaka
December 05, 2017
Tweet
Share
More Decks by YUMOTO Michitaka
See All by YUMOTO Michitaka
Short Introduction for Kysely
gothedistance
1
370
Dive Into Single Fetch
gothedistance
1
230
クラフトマンシップ(職人魂)を湾岸MIDNIGHTから学ぼう / Learn Craftsmanship from Wangan Midnight
gothedistance
0
300
プロ野球をデータモデリングしてみたら沼だった件 / Baseball ERD Modeling to be obsessed
gothedistance
2
820
フロントエンド開発スタイルの変遷と、私がFlutterにハマったわけ
gothedistance
8
14k
ITプロジェクトのはじめ方 / How to work around software project
gothedistance
28
150k
私がITプランナーを志すようになった理由、そして、目指していること / bpstudy142_why_i_wanna_be_a_it_plannner
gothedistance
1
920
ITプランナーの必要性を小一時間問い詰めたい / Why We need IT-Planner.
gothedistance
0
14k
IT企画をちゃんとやりたい#01 ガイダンス資料 / IT Planning do well_01
gothedistance
0
6.5k
Other Decks in Technology
See All in Technology
クレジットカード決済基盤を支えるSRE - 厳格な監査とSRE運用の両立 (SRE Kaigi 2026)
capytan
6
2.8k
ブロックテーマでサイトをリニューアルした話 / 2026-01-31 Kansai WordPress Meetup
torounit
0
480
Webhook best practices for rock solid and resilient deployments
glaforge
2
300
[CV勉強会@関東 World Model 読み会] Orbis: Overcoming Challenges of Long-Horizon Prediction in Driving World Models (Mousakhan+, NeurIPS 2025)
abemii
0
150
StrandsとNeptuneを使ってナレッジグラフを構築する
yakumo
1
120
Tebiki Engineering Team Deck
tebiki
0
24k
Cloud Runでコロプラが挑む 生成AI×ゲーム『神魔狩りのツクヨミ』の裏側
colopl
0
130
SREが向き合う大規模リアーキテクチャ 〜信頼性とアジリティの両立〜
zepprix
0
470
登壇駆動学習のすすめ — CfPのネタの見つけ方と書くときに意識していること
bicstone
3
130
SchooでVue.js/Nuxtを技術選定している理由
yamanoku
3
180
Greatest Disaster Hits in Web Performance
guaca
0
280
FinTech SREのAWSサービス活用/Leveraging AWS Services in FinTech SRE
maaaato
0
130
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Are puppies a ranking factor?
jonoalderson
1
2.7k
Facilitating Awesome Meetings
lara
57
6.8k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
760
Designing Powerful Visuals for Engaging Learning
tmiket
0
240
WCS-LA-2024
lcolladotor
0
450
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
160
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
110
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
450
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
0
2.4k
Transcript
Spring boot + Kotlinで Webサービスをサクッと作ってみた by makoto yuri
自己紹介 経験が長い→ C, C# 最近やってる→Java / Spring boot / JS
好き → Scala / Play Framework 由利 誠 (withpop) @anoparanominal (twitter) https://anopara.net (blog) フリーランス
伝えたいこと • ScalaやPlayと比較してJavaやSpringはど う感じたか • Spring bootを使った感想 • Spring boot
+ Kotlinの組み合わせはどうな のか
None
帳票作成サービス Docurain • Excelで作った帳票テンプレートにJSONでデー タを流し込んでPDF/Excel/画像を返却 • If/foreachなどの制御構造を使用可能 • Excelの機能(グラフ、スタイル、数式)が大体 動作する
• プレビュー版公開中なのでご興味がある方は是 非
簡単なデモ
Docurainの開発 Load Balancer Console / API Application Server Core Engine
Server Redis Maria DB Spring boot / Kotlin S3
Spring bootの良い点 • デプロイが超絶簡単 – executable jarへのシンボリックリンクをinit.d下に貼 るだけ • フルスタックなのでライブラリ選定で悩まない
• Spring Security便利 – Redisへのセッション吐き出し – 認可 – BCrypt • Tomcatで動く – Tomcatで動くことを要求されることが多い • あまり特殊なことをしなければ生産性がとても 高い
Spring bootのつらみ • annotationに頼りすぎ – 処理が散逸する 関心事が一つにまとまらない – 実行しないとエラーが分からない –
知らないと辛い(学習コストが高い) • Controllerの作り方がわかりにくい – クッキーをいじるには?Statusコードはどうすれ ばいいの?入出力のContent-Typeを動的に変更す るには? – 入力(Request)と出力(Response)の型がガッ チリ決まっててほしい
Spring bootのつらみの例 @Controller @ResponseBody class UserController { @GetMapping(“/users/{userId}”) fun getUser(@PathVariable
userId: String): Boolean { return userModel.getUserId(userId) ?: UserNotFoundException() } } @ResponseStatus(HttpStatus.NOT_ACCEPTABLE) class UserNotFoundException() : Exception() @ControllerAdvice class ExceptionHandler { @ExceptionHandler(UserNotFoundException::Class) fun userNotFound(): ResponseEntity<String>{ return ResponseEntity(“user not found.”, HttpStatus.NOT_FOUND) } Userを返却するという関心事が 散逸してしまう。 せめてgetUser()の中で完結して ほしい
Kotlin + Springの良い点 • 「Kotlinだから出来ない」は無かった • 拡張メソッドが充実してて痒いところに 手が届く – joinString,
stripMargin, use • Null safetyの演算子はまあまあ便利 – 特定の問題を解決するためだけに演算子を定 義してしまうのは個人的にはあんまり綺麗と は思わない • Kotlinの学習コストは低め
Kotlin + Springのつらみ • String Interpolationが常時動作するのがうざい 例: @Value(“¥${foo.baa}”) • Beanを定義するときにdata
classの恩恵が薄い。 Lombokのほうが楽に感じた • パターンマッチもScala比で出来ることが少なく なってる • 落とし穴が多い気がする(Kotlinの言語仕様)
fun foo(): Boolean { return listOf(1, 2, 3).all { return
it == 1 } } 落とし穴の例 foo()の実行結果は? その他の愚痴→ http://anopara.net/2017/09/16/kotlinの気に入らないところ/
まとめ • Spring boot / Kotlinの組み合わせはプロダク トでも十分使える • なんだかんだでKotlinはBetter Javaと言うに
相応しいと思う。Kotlin使えるなら使ったほ うが良い • Javaからの乗り換えを容易にした分、アドバ ンテージも小さくなってる気が • Javaも進化しているので、今Kotlinに積極的 に乗り換える理由があるかというと…?そもそ も人は集められるのか…?
おわり Docurain使ってみてね!!
Scala / Play との比較 • シンプルでわかりやすい – 学習コストはSpring bootよりPlayのほうが低いと感 じる
• ライブラリの選定で悩むところが多い – JSONライブラリだけで5~6くらいある? • filterやAOP相当の処理は関数合成で行う – ソースコードを追っていける • より型安全 • Scalaはコミュニティが殺伐としてる(※個人的感想)
Kotlin - Null Safety val x = request.getHeader(“Authorization”) ?: throw
NoAuthInfoException(“auth header required.”) val y = bob?.department?.head?.name C#にもNull許容型に似たような演算子がある。 PHPにもある?(よく知らない) Null安全のためにしか使えない演算子よりも、モナドとモナド用の構文 があったほうが汎用性があるような…しかしそれを言うとKotlinである必 要が無いし…以下略