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
JHipsterで学ぶ!Springによるサーバサイド開発手法
Search
Shinichi Kozake
May 19, 2017
Technology
5
9.3k
JHipsterで学ぶ!Springによるサーバサイド開発手法
JHipsterで学ぶ!Springによるサーバサイド開発手法
JJUG CCC 2017 Spring
#ccc_f1
Shinichi Kozake
May 19, 2017
Tweet
Share
More Decks by Shinichi Kozake
See All by Shinichi Kozake
アーキテクトとは
kozake
0
1.9k
Ionic React でサービス開発したお話
kozake
0
110
ドキッ!失敗だらけのシステム開発
kozake
1
750
やはり俺のWeb APIは間違えている
kozake
0
490
すごい大規模 たのしく作ろう
kozake
4
2.3k
KHipster ~JHipsterで始めるKotlin Web プログラミング~
kozake
0
810
Docker with JHipster
kozake
1
510
実践JHipster #jsug #sf_36
kozake
2
7.5k
Ionicでアプリ作ったよ!開発方法の紹介
kozake
2
940
Other Decks in Technology
See All in Technology
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
130
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
580
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
2
590
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
220
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
【若手エンジニア応援LT会】ソフトウェアを学んできた私がインフラエンジニアを目指した理由
kazushi_ohata
0
150
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
500
SREが投資するAIOps ~ペアーズにおけるLLM for Developerへの取り組み~
takumiogawa
1
190
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
990
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
7
810
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
210
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Designing for humans not robots
tammielis
250
25k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Rails Girls Zürich Keynote
gr2m
94
13k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
How to Ace a Technical Interview
jacobian
276
23k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Designing for Performance
lara
604
68k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Transcript
+)JQTUFSͰ ֶͿʂ 4QSJOHʹΑΔαʔόαΠυ։ൃख๏ ++6($$$4QSJOH DDD@G
4ZTUFN"SDIJUFDU 4ZTUFN"SDIJUFDU +BWB ͚͜͟ 8IPBN*
ࠂʂʂ
,"/+"7"1"35: େࡕ ຊϚΠΫϩιϑτؔࢧࣾ
ࠓͷΰʔϧ https://flic.kr/p/23R1Tx
+)JQTUFSͱ https://flic.kr/p/4ms8ZA
8IZ+)JQTUFS https://flic.kr/p/dGrMZz
-FBSO4QSJOH XJUI+)JQTUFS https://flic.kr/p/qex9y4
(SFBU4QSJOH 'VO+)JQTUFS ʘ͢͝ʔ͍ʂͨͷ͠ʔʂʗ
ҙࣄ߲ʂ https://flic.kr/p/qSmXKV
͜ͷΑ͏ͳͷ͍͟͝·ͥΜɻɻɻ ؗدװ؝د؆
ࠓͷରऀ 4QSJOHҰ௨Γษڧͨ͠ʂ ޮతͳ։ൃख๏Λ୳ٻத ໌ʹͰαʔϏεΛ্ཱ͍ͪ͛ͨʂ https://flic.kr/p/oowrrL ͰɺͲ͏։ൃ͢Εʁ
"HFOEB (FUUJOH4UBSU +)JQTUFSͱ -FBSOXJUI+)JQTUFS ·ͱΊ
"HFOEB (FUUJOH4UBSU +)JQTUFSͱ -FBSOXJUI+)JQTUFS ·ͱΊ
+)JQTUFSJTB:FPNBOHFOFSBUPS 4QSJOH#PPU "OHVMBS Ϟμϯ8FCΞϓϦέʔγϣϯΛૉૣ͘࡞ΕΔ͜ͱΛత Φʔϓϯιʔε :FPNBOϞμϯ8FCΞϓϦέʔγϣϯΛఏڙ͢Δ4DB⒎PMEπʔϧ ͯ͢(JU)VCͰ։ൃɻ"QBDIFMJDFOTFEɻ ਓͷ։ൃऀͱਓͷίϯτϦϏϡʔλ IUUQTHJUIVCDPNKIJQTUFSHFOFSBUPSKIJQTUFS
+)JQTUFSJT
4DB⒎PME5PPMJT ʮTDB⒎PMEʢεΩϟϑΥʔϧυʣʯʮʯͱ͍͏ҙຯͰ͢ɻ ʮʯͱ͍͏໊ͷ௨ΓɺΞϓϦέʔγϣϯͷͻͳܗͱͳΔ ιʔείʔυΛࣗಈੜ͠·͢ɻ
)JTUPSZ ݄ʹ+VMJFO%VCPJTʹΑͬͯ։࢝͞Ε·ͨ͠ɻ ࠷ॳͷެࣜϦϦʔε WFSTJPO ͕݄ɻ ͦΕҎདྷɺͷϦϦʔε͕͞Ε͍ͯ·͢ʂʢݱࡏʣ
8IZ+)JQTUFS https://flic.kr/p/dGrMZz
#PIWNCT 5RTKPI$QQV 4QSJOH#PPUͱ"OHVMBSɺ ૉΒ͍͠ϑϧελοΫϑϨʔϜϫʔΫͰ͢ɻ
#PIWNCT Ͱ͕͢ɺͱͯେ͖ͳϑϨʔϜϫʔΫͰ͢ɻ शಘίετେ͖͍Ͱ͢ɻ 5RTKPI$QQV
+)JQTUFSΛ༻͍Δ͜ͱͰ ͘͢8FCΞϓϦέʔγϣϯͷ ܗΛ࡞Δ͜ͱ͕Ͱ͖·͢ʂ ૉΒ͍͠αϯϓϧϓϩδΣΫτʹͱͬͯඇৗʹ༗ޮͰ͢ɻ
͜Ε͕+)JQTUFSͰੜ͞Εͨ8FCΞϓϦέʔγϣϯͷը໘Ͱ͢ɻ
ೝূೝՄͷΈ͕࠷ॳ͔Β༻ҙ͞Ε͍ͯ·͢ɻ ΦϓγϣϯʹΑΓ4PDJBMϩάΠϯ༻ҙ͞Ε·͢ɻ
JO *OUFSOBUJPOBMJ[BUJPO ༻ҙ͞Ε͓ͯΓɺ ݴޠλϒʹΑΓදࣔݴޠΛΓସ͑Δ͜ͱ͕ՄೳͰ͢ɻ
ΞϓϦέʔγϣϯΛཧ͢Δҝͷ༷ʑͳػೳ͕༻ҙ͞Ε͍ͯ·͢ɻ ྫ͑ཧϝτϦΫεΛબ͢Δͱɺ+7.ͷঢ়ଶ )551ϦΫΤετͳͲΛ֬ೝ͢Δ͜ͱ͕Ͱ͖·͢ɻ
ཧϔϧενΣοΫΛબ͢Δͱɺ σʔλϕʔεσΟεΫεϖʔεͷঢ়ଶΛ֬ೝ͢Δ͜ͱ͕Ͱ͖·͢ɻ
ཧઃఆΛબ͢Δͱɺ 4QSJOHDPOpHVSBUJPOTZTUFN&OWJSPONFOUͳͲɺ ֤छΞϓϦέʔγϣϯڥઃఆΛදࣔͰ͖·͢ɻ
ཧϩάΛબ͢Δͱɺϩάઃఆͷ֬ೝมߋ͕Ͱ͖·͢ɻ
ཧ"1*Λબ͢Δͱɺ4XBHHFS6*ʹΑΔ8FC"1*ͷυΩϡϝϯτ ΛදࣔͰ͖·͢ɻ
։ൃϞʔυͰىಈͨ͠߹ɺཧσʔλϕʔε͕બͰ͖·͢ɻ ͜ΕΛબ͢Δͱɺଓ͍ͯ͠Δσʔλϕʔεͷཧը໘ΛදࣔͰ͖·͢ɻ
σʔλϕʔεʹϩάΠϯ͢Δ͜ͱͰɺσʔλϕʔεͷ༰Λ֬ೝͰ͖·͢ɻ
શ͕ͯ࠷ॳ͔Β8FC"QQMJDBUJPOʹ༻ҙʂʂ
+)JQTUFSͰѹతޭʂ
"HFOEB (FUUJOH4UBSU +)JQTUFSͱ -FBSOXJUI+)JQTUFS ·ͱΊ
)PXUPJOTUBMM
ϩʔΧϧΠϯετʔϧ 7BHSBOUͰͷΠϯετʔϧ %PDLFSͰͷΠϯετʔϧ +)JQTUFSϩʔΧϧΠϯετʔϧͷଞɺ7BHSBOU%PDLFSΛͬͨ Πϯετʔϧ͕ՄೳͰ͢
ϩʔΧϧΠϯετʔϧ 7BHSBOUͰͷΠϯετʔϧ %PDLFSͰͷΠϯετʔϧ ࠓճɺϩʔΧϧΠϯετʔϧΛհ͠·͢
+BWBΛ0SBDMFͷ8FCαΠτ͔ΒΠϯετʔϧ Ϗϧυπʔϧ.BWFO͔(SBEMFΛબՄೳ ˞͜ΕΒ8SBQQFSͰࣗಈతʹΠϯετʔϧ͞ΕΔͷͰɺ༻ҙ͠ͳͯ͘0, HJUTDNDPN͔Β(JUΛΠϯετʔϧ /PEFKTͷ8FCαΠτ͔Β/PEFKTΛΠϯετʔϧ ҰॹʹΠϯετʔϧ͞ΕΔOQNΛ༻ͯ͠ +)JQTUFSʹඞཁͳOQNύοέʔδΛΠϯετʔϧ
OQNJOTUBMMHZP OQNJOTUBMMHCPXFS OQNJOTUBMMHHVMQDMJ OQNJOTUBMMHHFOFSBUPSKIJQTUFS :FPNBOͷΠϯετʔϧ #PXFSͷΠϯετʔϧ (VMQͷΠϯετʔϧ +)JQTUFSͷΠϯετʔϧ ^
0OMZGPS "OHVMBS+4
)PXUPDSFBUFBQQ
্هίϚϯυΛ࣮ߦ͢Δͱɺ+)JQTUFSͷΞϓϦέʔγϣϯ࡞͕࢝·Γ·͢ɻ NLEJSKKVH@DDD DEKKVH@DDD ZPKIJQTUFS
+)JQTUFSͰ.POPMJUIJDͳΞϓϦέʔγϣϯ ͘͠ɺϚΠΫϩαʔϏεΞϓϦέʔγϣϯΛબͰ͖·͢ɻ ██╗ ██╗ ██╗ ████████╗ ███████╗ ██████╗ ████████╗
████████╗ ███████╗ ██║ ██║ ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗ ██║ ████████║ ██║ ███████╔╝ ╚█████╗ ██║ ██████╗ ███████╔╝ ██╗ ██║ ██╔═══██║ ██║ ██╔════╝ ╚═══██╗ ██║ ██╔═══╝ ██╔══██║ ╚██████╔╝ ██║ ██║ ████████╗ ██║ ██████╔╝ ██║ ████████╗ ██║ ╚██╗ ╚═════╝ ╚═╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═╝ https://jhipster.github.io Welcome to the JHipster Generator v4.4.1 Documentation for creating an application: https://jhipster.github.io/creating-an-app/ Application files will be generated in folder: /Users/s_kozake/develop/jhipsterApp/hogeHipster ? (1/16) Which *type* of application would you like to create? (Use arrow keys) ❯ Monolithic application (recommended for simple projects) Microservice application Microservice gateway [BETA] JHipster UAA server (for microservice OAuth2 authentication)
+)JQTUFSΛ༻͍Δͱɺ্هྫͷΑ͏ͳϚΠΫϩαʔϏεΞϓϦέʔγϣϯߏ खܰʹߏஙͰ͖·͢ɻ
্هͷ͕KIJQTUFSHFOFSBUPSͰ࡞ՄೳͰ͢ɻ
͍͔ͭ͘ͷ࣭ʹ͑Δͱ ύοέʔδ໊ʁ σʔλϕʔεʁ ϓϩμΫτʁ ΞϓϦ໊ʁ ։ൃʁ .BWFO PS (SBEMF
ೝূํࣜʁ "OHVMBS+4 PS "OHVMBS FUDFUD
Server application generated successfully. Client application generated successfully. ϓϩδΣΫτͷ४උ͕Ͱ͖·ͨ͠ʂ
)PXUPSVO
Ϗϧυπʔϧʹ(SBEMFΛબͨ͠߹ɺ্هίϚϯυΛ࣮ߦ͢Δͱɺ ϙʔτͰ8FCΞϓϦέʔγϣϯ͕ىಈ͠·͢ɻ ϏϧτΠϯ5PNDBU͕ىಈ͠·͢ʂ HSBEMFXCPPUSVO
ϒϥβͰMPDBMIPTUͷϙʔτʹଓ͢Δͱɺ ը໘͕දࣔ͞Ε·͢ɻ
ΞΧϯτೝূΛબͯ͠ϩάΠϯ͠·͢ɻ BENJOͱVTFSͷΞΧϯτ͕σϑΥϧτͰ༻ҙ͞Ε͍ͯ·͢ɻ ॳظύεϫʔυΞΧϯτ໊ͱಉ͡Ͱ͢ɻ
BENJOΞΧϯτͰϩάΠϯ͢ΔͱɺΤϯςΟςΟཧ͕ φϏήʔγϣϯλϒʹදࣔ͞Ε·͢ɻ
$SFBUFFOUJUZ
+)JQTUFSͷΤϯςΟςΟαϒδΣωϨʔλΛ༻͍ͯɺ ্ͷΑ͏ͳ&OUJUZͱͦΕΛฤू͢Δ$36%ը໘Λੜ͠·͢ɻ
ZPKIJQTUFSFOUJUZBVUIPS ্هίϚϯυΛ࣮ߦͯ͠ɺ"VUIPS&OUJUZΛੜ͠·͢ɻ
͍͔ͭ͘ͷ࣭ʹ͑Δͱ ϑΟʔϧυͷܕʁ %50 ผʹͭ͘Δʁ ϑΟʔϧυ໊ʁ ϦϨʔγϣϯʁ όϦσʔγϣϯ ํ๏ʁ αʔϏεͷ
࡞Γํʁ FUDFUD
Everything is configured, generating the entity... ΤϯςΟςΟ͕࡞͞Ε·͢ʂ
ಉ༷ʹɺ#PPL&OUJUZΛੜ͠·͢ɻ ZPKIJQTUFSFOUJUZCPPL
ϩάΠϯ͢ΔͱɺΤϯςΟςΟʹ"VUIPSͱ#PPL͕Ճ͞Ε͍ͯ·͢ɻ
ΤϯςΟςΟ#PPLΛબ͢Δͱɺ$36%ը໘͕දࣔͰ͖·͢ɻ
ΤϯςΟςΟ#PPLͷදࣔը໘ɻ
ΤϯςΟςΟ#PPLͷฤूը໘ɻ
ΤϯςΟςΟ#PPLͷআ֬ೝμΠΞϩάɻ
ΤϯςΟςΟαϒδΣωϨʔλͷΘΓʹɺ+%-4UVEJPΛ༻͍Δ͜ͱग़དྷ·͢ɻ +%-4UVEJPϒϥβϕʔεͷ(6*πʔϧͰ͢ɻ +)JQTUFS%PNBJO-BOHVBHF +%- Λ༻͍ͯɺΤϯςΟςΟઃܭ͕Ͱ͖·͢ɻ
ZPKIJQTUFSJNQPSUKEMdKIJQTUFSKEMKI +%-4UVEJPͰ࡞ͨ͠ϑΝΠϧΛɺ্هίϚϯυͰಡΈࠐΉ͜ͱͰ ಉ༷ͷ͜ͱ͕Ͱ͖·͢ʂ
"HFOEB (FUUJOH4UBSU +)JQTUFSͱ -FBSOXJUI+)JQTUFS ·ͱΊ
? ? αʔόαΠυ։ൃͱͻͱ͜ͱͰݴͬͯɺߟ͑Δ͜ͱͨ͘͞Μ͋Γ·͢ɻ ͍͟։ൃ͢ΔͱͳΔͱɺʮ͜ΕͲ͏͢Εʁʯͱ໎͏͜ͱଟ͍Ͱ͢ɻ ϩάग़ྗ ೝূ ࠪূ 3&45GVM"1* Τϥʔॲཧ
ϖʔδϯά ޮྑ͍։ൃ ӡ༻ ηΩϡϦςΟ ΞϓϦߏ
ͦ͜Ͱɺ+)JQTUFS͕ग़ྗ͢ΔιʔείʔυΛࢀߟʹͯ͠ΈͯԿͰ͠ΐ͏ʂ ચ࿅͞Ε࣮ͨͷώϯτ͕ࢄΒ͍ͬͯΔͱࢥ͍·͢ʂ ϩάग़ྗ ೝূ ࠪূ 3&45GVM"1* Τϥʔॲཧ ϖʔδϯά ޮྑ͍։ൃ
ӡ༻ ηΩϡϦςΟ ΞϓϦߏ !
+)JQTUFSͰ ֶͿʂ 4QSJOHʹΑΔαʔόαΠυ։ൃख๏
+)JQTUFSͰ ֶͿʂ 4QSJOH։ൃͷϕετϓϥΫςΟε ͔ͯύΫΔ ΅ͦ
? ? ΞϓϦέʔγϣϯߏͬͯͲ͏͢Ε͍͍Ͱ͠ΐ͏͔ʁ ύοέʔδߏؚΊͯ໎͏͜ͱଟ͍Ͱ͢ΑͶɻ ϩάग़ྗ ೝূ ࠪূ 3&45GVM"1* Τϥʔॲཧ
ϖʔδϯά ޮྑ͍։ൃ ӡ༻ ηΩϡϦςΟ ΞϓϦߏ
ΞϓϦέʔγϣϯߏ 9GD 鱙鯮鱷鱝 鱭鲅鱈鲗 鲎鲁鱜鱬鲎 *QIG 4GUQWTEG *QIG 5GTXKEG
*QIG&61 *QIG 4GRQUKVQT[ *QIG 鱟鱑鲉鲎鱪鱇崎#12 .QIIKPI #URGEV 5GEWTKV[ %QPHKIWTCVKQP &QOCKP7UGT &GVCKN5GTXKEG
[packageName] │ ├── aop - AOP関連 ├── config -
JavaConfig関連 ├── domain - ドメイン層のBean定義 ├── repository - リポジトリ層のBean定義 ├── security - セキュリティ関連 ├── service - サービス層のBean定義 └── web - プレゼンテーション層 └── rest - Spring MVC RESTコントローラの定義 ύοέʔδߏ ύοέʔδߏΞϓϦέʔγϣϯߏʹԊͬͨͷͱͳ͍ͬͯΔͨΊɺ Ͳ͜ʹԿ͕͋Δͷ͔͕େมΘ͔Γ͍͢Ͱ͢ɻ
ϩάग़ྗͲ͏͢Ε͍͍ͷͰ͠ΐ͏Ͷʁ $PNNPOT-PHHJOH -PH+ -PHCBDL 4-'+ +6- -PH4UBTIͱͷ࿈ܞ +BWBϓϥοτϑΥʔϜͰͷϩάग़ྗɺ৭ʑͱબࢶ͕͋Γ͗ͯ͢Έ·͢ɻ
? ? ೝূ ࠪূ 3&45GVM"1* Τϥʔॲཧ ϖʔδϯά ޮྑ͍։ൃ ӡ༻ ηΩϡϦςΟ ΞϓϦߏ ϩάग़ྗ
dependencies { : compile "org.springframework.boot:spring-boot-starter-logging" : } CVJMEHSBEMF 4QSJOH#PPUʹ$PNNPOT-PHHJOH"1*Λআ͍ͯඞਢͷϩΪϯάґଘؔ͋Γ·ͤΜɻ
ྫ͑-PHCBDLΛ༻͢Δ߹ɺຊདྷ༷ʑͳઃఆΛՃ͢Δඞཁ͕͋Γ·͢ɻ ʮTQSJOHCPPUTUBSUFSMPHHJOHʯΛґଘʹΈࠐΉ͜ͱͰɺΫϥεύεʹج͍ͮͯ ϩΪϯάΛઃఆΛͯ͘͠Ε·͢ɻ -PHCBDL͕༗ޮͳΒͦΕ͕࠷ॳʹ࠾༻͞Ε·͢ɻ +)JQTUFSͰɺʮTQSJOHCPPUTUBSUFSMPHHJOHʯΛґଘʹΈࠐΜͰ͍·͢ɻ ϩάग़ྗ
ϩάग़ྗ ΫϥεύεͷϧʔτʹMPHCBDLTQSJOHYNM͕͋Εɺͦͷઃఆ͕࠾༻͞Ε·͢ɻ 4QSJOH#PPUJODMVEFՄೳͳσϑΥϧτઃఆΛఏڙ͍ͯ͠·͢ɻ ͜ͷઃఆΛมߋ͢Δ͜ͱͰɺϩάϨϕϧͳͲͷมߋ৽ͨͳՃ͕ՄೳͰ͢ɻ <?xml version="1.0" encoding="UTF-8"?> <configuration
scan="true"> <include resource="org/springframework/boot/logging/logback/base.xml"/> : <logger name="com.mycompany.myapp" level="#logback.loglevel#"/> <logger name="io.github.jhipster" level="DEBUG"/> <logger name="javax.activation" level="WARN"/> : <root level="#logback.loglevel#"> <appender-ref ref="CONSOLE"/> </root> </configuration> SFTPVSDFTMPHCBDLTQSJOHYNM σϑΥϧτઃఆ
ϩάग़ྗ @Pointcut("within(jjug_ccc.repository..*) " + "|| within(jjug_ccc.service..*) " + "||
within(jjug_ccc.web.rest..*)") public void loggingPointcut() { } @AfterThrowing(pointcut = "loggingPointcut()", throwing = "e") public void logAfterThrowing( JoinPoint joinPoint, Throwable e) { : } @Around("loggingPointcut()") public Object logAround( ProceedingJoinPoint joinPoint) throws Throwable { : } BPQMPHHJOH-PHHJOH"TQFDU +)JQTUFSͰϩάग़ྗʹ"01Λ׆༻͍ͯ͠·͢ɻ MPHHJOH1PJOUDVUͰϩάग़ྗ͢ΔൣғΛࢦఆͯ͠ɺϝιουͷ։࢝ɾऴྃྫ֎ൃੜ࣌ ͷϩάग़ྗ͕Ͱ͖ΔΑ͏ʹͳ͍ͬͯ·͢ɻ ϩάग़ྗ ൣғͷࢦఆ ϝιουͷ ։࢝ɾऴྃ ྫ֎ൃੜ࣌
ϩάग़ྗ @Configuration @EnableAspectJAutoProxy public class LoggingAspectConfiguration { @Bean
@Profile(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) public LoggingAspect loggingAspect(Environment env) { return new LoggingAspect(env); } } DPOpH-PHHJOH"TQFDU$POpHVSBUJPO "01Λར༻ͯ͠ग़ྗ͢Δϩάɺ։ൃϞʔυ͚ͩͰ༗ޮͱͳΔઃఆʹͳ͍ͬͯ·͢ɻ 1SPpMFΞϊʔςʔγϣϯΛ༻͍Δ͜ͱͰɺಛఆͷڥԼͰͷΈ#FBOఆٛΛ༗ޮʹ͢Δ͜ͱ͕ ՄೳͱͳΓ·͢ɻ ։ൃ࣌ͷΈ༗ޮ
ϩάग़ྗ @GetMapping("/logs") @Timed public List<LoggerVM> getList() { LoggerContext context
= (LoggerContext) LoggerFactory.getILoggerFactory(); return context.getLoggerList() .stream() .map(LoggerVM::new) .collect(Collectors.toList()); } XFCSFTU-PHT3FTPVSDF ·ͨɺϩάઃఆΛฦ͢8FC"1*͕+)JQTUFSͰ࠷ॳ͔Β༻ҙ͞Ε͍ͯ·͢ɻ ্ͷίʔυɺϩάઃఆΛฦ͢8FCϋϯυϥʔͰ͢ɻ
ϩάग़ྗ @PutMapping("/logs") @ResponseStatus(HttpStatus.NO_CONTENT) @Timed public void changeLevel(@RequestBody LoggerVM jsonLogger)
{ LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); context.getLogger(jsonLogger.getName()) .setLevel(Level.valueOf(jsonLogger.getLevel())); } XFCSFTU-PHT3FTPVSDF ͞ΒʹɺϩάϨϕϧΛมߋ͢Δ8FCϋϯυϥʔ༻ҙ͍ͯ͠·͢ʂ
ϩάग़ྗ ઌ΄Ͳͷ8FC"1*Λ༻͍Δ͜ͱͰɺཧϩάͷը໘͕࣮ݱ͞Ε͍ͯ·͢ʂ
ϩάग़ྗ public LoggingConfiguration(…) { : if (jHipsterProperties.getLogging() .getLogstash().isEnabled()) {
addLogstashAppender(context); : } } DPOpH-PHHJOH$POpHVSBUJPO +)JQTUFSͰɺMPHTUBTIͱ࿈ܞ͢Δίʔυ༻ҙ͞Ε͍ͯ·͢ɻ ઃఆΛՃ͢Δ͜ͱͰɺϩά༰ΛඇಉظʹMPHTUBTI࿈ܞͰ͖·͢ɻ
Here!
ೝূͬͯͲ͏͢Ε͍͍ͷͰ͠ΐ͏ʁ ैདྷͷηογϣϯํࣜͰ͍͍ͷ͔ͳʁ ࠷ۙͰɺ0"VUIΛ༻͍ͨೝূํࣜͱ͔৭ʑฉ͍ͨΓ͠·͕͢ɻ ? ? ࠪূ 3&45GVM"1* Τϥʔॲཧ ϖʔδϯά
ޮྑ͍։ൃ ӡ༻ ηΩϡϦςΟ ΞϓϦߏ ϩάग़ྗ ೝূ
ೝূ )5514FTTJPO"VUIFOUJDBUJPO TUBUFGVM EFGBVMU4QSJOH4FDVSJUZNFDIBOJTN 0"VUI"VUIFOUJDBUJPO TUBUFMFTT XJUIBO0"VUITFSWFSJNQMFNFOUBUJPO +85BVUIFOUJDBUJPO TUBUFMFTT
XJUIBUPLFO +)JQTUFSͰɺΞϓϦέʔγϣϯ࡞࣌ʹ ैདྷͷ)551ηογϣϯΛ༻͍ͨೝূํࣜͷ΄͔ɺ 0"VUI+85Λ༻͍ͨೝূํࣜΛબ͢Δ͜ͱ͕ग़དྷ·͢ɻ
ೝূ )5514FTTJPO"VUIFOUJDBUJPO ݹయతͳ4QSJOH4FDVSJUZͷೝূϝΧχζϜͰ͢ɻ )551ηογϣϯΛ༻͢ΔͷͰɺεςʔτϑϧɻ ΞϓϦέʔγϣϯΛෳͷαʔόʔʹεέʔϧ͢Δ߹ɺ εςΟοΩʔηογϣϯΛ࣋ͭϩʔυόϥϯα͕ඞཁͰ͢ɻ
ೝূ 0"VUI"VUIFOUJDBUJPO εςʔτϨεͳηΩϡϦςΟϝΧχζϜͰ͢ɻ 4QSJOH4FDVSJUZ0"VUIΛ༻͍࣮ͯݱ͍ͯ͠·͢ɻ ηΩϡϦςΟτʔΫϯΛ֨ೲ͢ΔͨΊʹσʔλϕʔεςʔϒϧ͕ඞཁɻ
ೝূ 0"VUI"VUIFOUJDBUJPO $MJFOU +)JQTUFS"QQ ೝূαʔό Ϧιʔεαʔό 3FTPVSDF0XOFS 1BTTXPSE$SFEFOUJBMT "DDFTT5PLFO
8FCΞϓϦέʔγϣϯ͕ɺೝূαʔό݉ϦιʔεαʔόʹͳΔΠϝʔδɻ ೝূʮ3FTPVSDF0XOFS1BTTXPSE$SFEFOUJBMTάϥϯτछผʯͰ࣮ࢪɻ
ೝূ +85"VUIFOUJDBUJPO +40/8FCτʔΫϯΛ༻͍ͨεςʔτϨεͳηΩϡϦςΟʔػߏͰ͢ɻ ෳͷαʔόʔʹΞϓϦέʔγϣϯΛεέʔϧ͍ͨ͠߹ʹศརɻ ӬଓԽϝΧχζϜΛඞཁͱ͠ͳ͍ͨΊɺ0"VUIΑΓ༻ͱ࣮ ͕؆୯ɻ ϩάΠϯ໊ͱݖݶΛอ࣋͢Δ҆શͳτʔΫϯΛ༻ɻ τʔΫϯॺ໊͞Ε͍ͯΔͨΊɺதΛݟΔ͜ͱͰ͖Δ͚Ͳɺ Ϣʔβʔ͕มߋ͢Δ͜ͱ͕Ͱ͖ͳ͍ɻ
ೝূ +85BVUIFOUJDBUJPO $MJFOU +)JQTUFS"QQ +85'JMUFS ίϯτϩʔϥ JWT
ೝূ +TPO8FC5PLFO FZ+IC(DJ0J+*6[6Y.J+FZ+[E8*J0J+I;(QCJ*T*N'E(HJ0J +45Y'9'&56M0-'+15&7G77/'6J*T*N7D$*.52/5& /K&/OW3H;FY4/UYBH(ORSVN*7HRQ)""#EE&5@L NR-R";X9"49ZMIF%E,L*VXE5&:5[,4%S8STK1 GKH ্ͷจࣈɺ+)JQTUFSͰੜ͞Εͨ8FCΞϓϦέʔγϣϯͷϦΫΤετϔομ Ͱૹ৴͞Ε͍ͯΔ+85Ͱ͢ɻ
+85)&"%&3ɺ1":-0"%ɺ7&3*':4*(/"563&ͷͭͷ෦Ͱߏ ͞Ε͍ͯ·͢ɻ
ೝূ +TPO8FC5PLFO FZ+IC(DJ0J+*6[6Y.J+FZ+[E8*J0J+I;(QCJ*T*N'E(HJ0J +45Y'9'&56M0-'+15&7G77/'6J*T*N7D$*.52/5& /K&/OW3H;FY4/UYBH(ORSVN*7HRQ)""#EE&5@L NR-R";X9"49ZMIF%E,L*VXE5&:5[,4%S8STK1 GKH )&"%&3ʹΞϧΰϦζϜ͕ࣔ͞Ε͓ͯΓɺ \
BMH)4 ^
ೝূ +TPO8FC5PLFO FZ+IC(DJ0J+*6[6Y.J+FZ+[E8*J0J+I;(QCJ*T*N'E(HJ0J +45Y'9'&56M0-'+15&7G77/'6J*T*N7D$*.52/5& /K&/OW3H;FY4/UYBH(ORSVN*7HRQ)""#EE&5@L NR-R";X9"49ZMIF%E,L*VXE5&:5[,4%S8STK1 GKH 1":-0"%ʹೝূσʔλ͕ೖ͍ͬͯ·͢ɻ \
TVCBENJO BVUI30-&@"%.*/ 30-&@64&3 FYQ ^
@PostMapping("/authenticate") public ResponseEntity authorize(...) { : boolean rememberMe =
(loginVM.isRememberMe() == null) ? false : loginVM.isRememberMe(); String jwt = tokenProvider.createToken( authentication, rememberMe); response.addHeader(JWTConfigurer.AUTHORIZATION_HEADER, "Bearer " + jwt); return ResponseEntity.ok(new JWTToken(jwt)); : TFDVSJUZKXU+85'JMUFS ೝূ ্ͷίʔυ+85Λ༻͍ͨೝূ෦Ͱ͢ɻ ೝূ0,ͷ߹ɺ+85τʔΫϯΛ࡞ͯ͠ɺ)551Ϩεϙϯεͱͯ͠ฦ٫͍ͯ͠·͢ɻ +85ੜ )551Ϩεϙϯεͱͯ͠ฦ٫
@Override public void doFilter(…) throws … { : String
jwt = resolveToken(httpServletRequest); if (StringUtils.hasText(jwt) && this.tokenProvider.validateToken(jwt)) { Authentication authentication = this.tokenProvider.getAuthentication(jwt); SecurityContextHolder.getContext() .setAuthentication(authentication); } filterChain.doFilter(servletRequest, servletResponse); : TFDVSJUZKXU+85'JMUFS ೝূ ্ͷίʔυ+85'JMUFSͷ࣮Ͱ͢ɻ )551ϦΫΤετϔομͷτʔΫϯΛݕূͯ͠ɺೝূ͢ΔγϯϓϧͳίʔυͰ͢ɻ ϦΫΤετ͔Β KXUऔಘ KXU͕༗ޮͳΒ KXU͔Β ೝূ࡞
ೝূ )5514FTTJPO"VUIFOUJDBUJPO TUBUFGVM EFGBVMU4QSJOH4FDVSJUZNFDIBOJTN 0"VUI"VUIFOUJDBUJPO TUBUFMFTT XJUIBO0"VUITFSWFSJNQMFNFOUBUJPO +85BVUIFOUJDBUJPO TUBUFMFTT
XJUIBUPLFO ݸਓతʹɺ 440ͱ͔Λߟ͑ͳ͚Εʣγϯϓϧͳ+85Λ༻͍ͨೝূํ͕ࣜΈͰ͢ɻ
4QSJOH4FDVSJUZɺઃఆ͕େมͰ͢ΑͶʁ ݁ہɺͳʹΛͲ͏ઃఆ͢Ε͍͍ΜͰ͚ͨͬ͠ʁ ͱΉ͜ͱ͋Γ·͢ɻ ? ? ࠪূ 3&45GVM"1* Τϥʔॲཧ ϖʔδϯά
ޮྑ͍։ൃ ӡ༻ ΞϓϦߏ ϩάग़ྗ ೝূ ηΩϡϦςΟ
ηΩϡϦςΟ +)JQTUFSͰɺ"OHVMBS 4QSJOHͷߏʹదͨ͠ηΩϡϦςΟઃఆ͕ɺ ࣍ͷ+BWB$POpHͱͯ͠༻ҙ͞ΕΔͷͰศརͰ͢ʂ ɹɾ4FDVSJUZ$POpHVSBUJPO ɹɾ8FC$POpHVSFS ͦͷத͔Βɺز͔ͭͷηΩϡϦςΟઃఆΛհ͠·͢ɻ
@Override protected void configure(HttpSecurity http) throws Exception { http
.csrf() .csrfTokenRepository( CookieCsrfTokenRepository.withHttpOnlyFalse()) : } DPOpH4FDVSJUZ$POpHVSBUJPO ηΩϡϦςΟ $43'ରࡦͷઃఆͰ͢ɻ +)JQTUFSͰɺϑϩϯτΤϯυͷ"OHVMBSʹదͨ͠$43'ઃఆ͕͞Ε͍ͯ·͢ɻ 0"VIU+85Λೝূํࣜʹબͨ͠߹ɺ$43'ରࡦແޮͱͳΓ·͢ɻ
ೝূ $MJFOU +)JQTUFS"QQ <)551ϔομ> 9943'50,&/$43'τʔΫϯ 4FU$PPLJF 943'50,&/$43'τʔΫϯ "OHVMBSͷྲّྀʹԊͬͯɺ$43'τʔΫϯ$PPLJFͷʮ943'50,&/ʯʹઃఆͯ͠ฦ͠ɺ ϦΫΤετϔομͷʮ9943'50,&/ʯͰड͚औΓ·͢ɻ
+BWB4DSJQU͔Β$PPLJFΛࢀর͢Δඞཁ͕͋ΔͨΊɺ$PPLJFͷ)UUQ0OMZଐੑΛGBMTFʹ ઃఆ͍ͯ͠·͢ɻ
@Override protected void configure(HttpSecurity http) throws Exception { http
: .and() .addFilterBefore( corsFilter, UsernamePasswordAuthenticationFilter.class) : } DPOpH4FDVSJUZ$POpHVSBUJPO ηΩϡϦςΟ $034 $SPTT0SJHJO3FTPVSDF4IBSJOH ͷઃఆͯ͘͠Ε͍ͯ·͢ʂ 6TFSOBNF1BTTXPSE"VUIFOUJDBUJPO'JMUFSͷલʹDPST'JMUFSΛՃ͍ͯ͠·͢ɻ
@Bean public CorsFilter corsFilter() { UrlBasedCorsConfigurationSource source = new
UrlBasedCorsConfigurationSource(); CorsConfiguration config = jHipsterProperties.getCors(); if (config.getAllowedOrigins() != null && !config.getAllowedOrigins().isEmpty()) { source.registerCorsConfiguration("/api/**", config); source.registerCorsConfiguration("/v2/api-docs", config); } return new CorsFilter(source); } DPOpH8FC$POpHVSBUJPO ηΩϡϦςΟ ϓϩύςΟʹ$034ͷઃఆ͕͋Δ߹ɺ$034ઃఆ͕༗ޮʹͳΓ·͢ɻ ͳ͓ɺσϑΥϧτͰ։ൃϞʔυͷΈɻͯ͢ͷ0SJHJO͕ڐՄͰઃఆ͞Ε͍ͯ·͢ɻ $034ઃఆ͕ ༗ޮͳ߹
@Override protected void configure(HttpSecurity http) throws Exception { http
: .and() : .exceptionHandling() .authenticationEntryPoint( http401UnauthorizedEntryPoint() ) : } DPOpH4FDVSJUZ$POpHVSBUJPO ηΩϡϦςΟ ೝূΤϥʔ͕ൃੜͨ͠߹ʹͷεςʔλείʔυΛฦ͢ઃఆΛ͍ͯ͠·͢ɻ ͜ͷઃఆΛ͠ͳ͍ͱɺ-PHJO6SM"VUIFOUJDBUJPO&OUSZ1PJOU͕༗ޮʹͳͬͯ ೝূΤϥʔ࣌ʹϩάΠϯϖʔδ͕දࣔ͞Ε·͢ɻ Λฦ͢ઃఆ
@Override public void configure(WebSecurity web) throws Exception { web.ignoring()
.antMatchers(HttpMethod.OPTIONS, "/**") .antMatchers("/app/**/*.{js,html}") .antMatchers("/bower_components/**") .antMatchers("/i18n/**") .antMatchers("/content/**") .antMatchers("/swagger-ui/index.html") .antMatchers("/test/**") .antMatchers("/h2-console/**"); } DPOpH4FDVSJUZ$POpHVSBUJPO ηΩϡϦςΟ 4QSJOH4FDVSJUZͷର֎ͱ͢Δ63-ઃఆ͞Ε͍ͯΔͷͰศརͰ͢ɻ ৽͘͠ର֎ͱ͢Δ63-ΛՃ͢Δ߹ɺ͜͜ͷઃఆʹՃ͢ΕେৎͰ͢ɻ
ࠪূΛͱΔΑ͏ʹ͓٬͞ΜʹݴΘΕ͚ͨͲɺɺ Ͳ͏͢Δͷ͕Ұ൪͍͍ͷͰ͠ΐ͏Ͷʁ ? ? 3&45GVM"1* Τϥʔॲཧ ϖʔδϯά ޮྑ͍։ൃ ӡ༻
ηΩϡϦςΟ ΞϓϦߏ ϩάग़ྗ ೝূ ࠪূ
dependencies { : compile "org.springframework.boot:spring-boot-actuator" : } CVJMEHSBEMF 4QSJOH#PPU"DUVBUPSɺࠪূͷػೳΛఏڙͯ͘͠Ε·͢ʂ
ࠪূ
public interface AuditEventRepository { void add(AuditEvent event); List<AuditEvent> find(Date
after); List<AuditEvent> find(String principal, Date after); List<AuditEvent> find(String principal, Date after, String type); } PSHTQSJOHGSBNFXPSLCPPUBDUVBUFBVEJU"VEJU&WFOU3FQPTJUPSZ ࠪূ 4QSJOH#PPU"DUVBUPSʹ༻ҙ͞Εͨ"VEJU&WFOU3FQPTJUPSZΠϯλϑΣʔεΛ࣮͢Δ͜ͱͰɺ ࠪূͷΠϕϯτΛऔಘͰ͖·͢ɻ
/** * An implementation of Spring Boot's AuditEventRepository. */
@Repository public class CustomAuditEventRepository implements AuditEventRepository { private final PersistenceAuditEventRepository persistenceAuditEventRepository; private final AuditEventConverter auditEventConverter; : } PSHTQSJOHGSBNFXPSLCPPUBDUVBUFBVEJU"VEJU&WFOU3FQPTJUPSZ ࠪূ +)JQTUFSͰɺ"VEJU&WFOU3FQPTJUPSZΠϯλϑΣʔεΛ࣮ͨ͠ɺ $VTUPN"VEJU&WFOU3FQPTJUPSZ͕༻ҙ͞Ε͍ͯ·͢ɻ
ࠪূ $VTUPN "VEJU&WFOU3FQPTJUPSZ 1FSTJTUFODF "VEJU&WFOU3FQPTJUPSZ +)*@1&34*45&/5@"6%*5@&7&/5 +)*@1&34*45&/5@"6%*5@&75@%"5" $VTUPN"VEJU&WFOU3FQPTJUPSZ͕1FSTJTUFODF"VEJU&WFOU3FQPTJUPSZΛݺͼग़͢͜ͱͰɺ σʔλϕʔεʹࠪূΛอଘ͠·͢ɻ
ࠪূ
ࠪূ ࠪূɺཧࠪͷը໘Ͱࢀর͢Δ͜ͱ͕ग़དྷ·͢ɻ
+40/Λฦ͢8FC"1*ͰϖʔδωʔγϣϯΛ࣮͢Δ߹ɺલʗޙϖʔδ ࠷ॳʗ࠷ޙͷϖʔδͷΑ͏ͳใΛͲ͏ฦ٫͢Ε͍͍ͷͰ͠ΐ͏ʁ +40/ͷதʢϨεϙϯεͷϘσΟʣใΛೖΕΔʁ ϨεϙϯεϔομʹೖΕΔʁ ? ? ࠪূ ޮྑ͍։ൃ ӡ༻
ΞϓϦߏ ϩάग़ྗ ೝূ ηΩϡϦςΟ 3&45GVM"1* ϖʔδϯά Τϥʔॲཧ
@RestController @RequestMapping("/management/audits") public class AuditResource { @GetMapping public
ResponseEntity<List<AuditEvent>> getAll( @ApiParam Pageable pageable) { Page<AuditEvent> page = auditEventService.findAll(pageable); HttpHeaders headers = PaginationUtil .generatePaginationHttpHeaders( page, "/management/audits"); return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK); } } XFCSFTU"VEJU3FTPVSDF 3&45ϖʔδϯά +)JQTUFSͰɺϖʔδϯάͷใ)551ϔομʹઃఆͯ͠ฦ͍ͯ͠·͢ɻ
3&45ϖʔδϯά 3'$ -JOLIFBEFS ϨεϙϯεϔομʹϖʔδϯάใΛೖΕΔํ๏ΛఏҊ͍ͯ͠Δ )551ϔομʹઃఆ͢Δϖʔδϯάใɺ3'$ʹै༷ͬͨΛ࠾༻͍ͯ͠·͢ɻ NBOBHFNFOUBVEJUT QBHFTJ[FSFMlMBTU NBOBHFNFOUBVEJUT
QBHFTJ[FSFMpSTU
ΤϥʔϋϯυϦϯάͲ͏ͨ͠Β͍͍ͷͰ͠ΐ͏ʁ 'JMUFS "01Λ༻ͨ͠ྫ֎ิ &YDFQUJPO)BOEMFS ? ? ࠪূ ޮྑ͍։ൃ
ӡ༻ ΞϓϦߏ ϩάग़ྗ ೝূ ηΩϡϦςΟ 3&45GVM"1* ϖʔδϯά Τϥʔॲཧ
3&45Τϥʔॲཧ +)JQTUFSͰɺ!$POUSPMMFS"EWJDFΛͬͯ ΤϥʔϋϯυϦϯάΛ͍ͯ͠·͢ɻ $POUSPMMFS"EWJDFΞϊςʔγϣϯΛ༻͍Δ͜ͱͰɺ $POUSPMMFSΛԣஅͯ͠ྫ֎ΛϋϯυϦϯά͢Δ͜ͱ͕ ՄೳͱͳΓ·͢ɻ
@ControllerAdvice public class ExceptionTranslator { @ExceptionHandler(ConcurrencyFailureException.class) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody
public ErrorVM processConcurrencyError( ConcurrencyFailureException ex) { return new ErrorVM( ErrorConstants.ERR_CONCURRENCY_FAILURE); } : } SFTUFSSPST&YDFQUJPO5SBOTMBUPS 3&45Τϥʔॲཧ &YDFQUJPO5SBOTMBUPSΫϥεͷͳ͔ͰҰ௨ΓͷΤϥʔॲཧ͕ఆٛ͞Ε͍ͯ·͢ͷͰɺ ৽ͨʹΞϓϦέʔγϣϯಠࣗͷΤϥʔϋϯυϦϯάΛՃ͍ͨ͠߹ɺ ͜͜ʹՃ͢Ε͍͍͚ͩͰ͢ɻͱͯศརͰ͢ɻ ഉଞϩοΫʹ ࣦഊͨ͠߹ $POqJDU Λฦ͢ɻ
։ൃޮΛ͋͛ΔʹͲ͏ͨ͠Β͍͍ͩΖ͏ʁ ͳΜ͔͍͍πʔϧͳ͍͔ͳʙʁͱ͔Έ·͢ΑͶɻ ? ? ࠪূ ӡ༻ ΞϓϦߏ ϩάग़ྗ ೝূ
ηΩϡϦςΟ 3&45GVM"1* ϖʔδϯά Τϥʔॲཧ ޮྑ͍։ൃ
: dependencies { compile "org.springframework.boot:spring-boot-devtools" } : QSPpMF@EFWHSBEMF ޮྑ͍։ൃ
4QSJOH#PPU%FWUPPMTΛ༻͍Δ͜ͱʹΑΓɺΞϓϦέʔγϣϯΛlIPUSFTUBSUzͰ͖·͢ɻ ϓϩδΣΫτͷΫϥε͕ίϯύΠϧ͞ΕΔͱɺมߋΛݕͯ͠ΞϓϦΛ࠶ىಈ͠·͢ɻ +)JQTUFSͰɺ։ൃϞʔυͰىಈ͚ͨ࣌ͩ͜͠ͷػೳ͕༗ޮʹͳΔΑ͏ʹઃఆ͞Ε͍ͯ·͢ɻ : if (project.hasProperty('prod')) { apply from: 'gradle/profile_prod.gradle' } else { apply from: 'gradle/profile_dev.gradle' } : CVJMEHSBEMF
ޮྑ͍։ൃ σϑΥϧτઃఆͰɺ*OUFMMJ+*%&"ΞϓϦέʔγϣϯ࣮ߦதʹ ࣗಈίϯύΠϧ͠·ͤΜɻ ʮอଘ࣌ʹίϯύΠϧʯػೳΛ༗ޮʹ͢Δʹɺ *OUFMMJ+*%&"1SFGFSFODFT#VJME &YFDVUJPO %FQMPZNFOU$PNQJMFS Λબͯ͠ɺl.BLFQSPKFDUBVUPNBUJDBMMZzΛ༗ޮʹ͍ͯͩ͘͠͞ɻ ͦͷޙɺҎԼͷΩʔͰ"DUJPOXJOEPXΛ։͍ͯɺ
-JOVY$53- 4)*'5 " .BD0494)*'5 $0.."/% " 8JOEPXT$53- "-5 4)*'5 ʮ3FHJTUSZʯͱೖྗ͠ɺzDPNQJMFSBVUPNBLFBMMPXXIFOBQQSVOOJOHzΛ ༗ޮʹ͍ͯͩ͘͠͞ɻ
+)JQTUFS։ൃऀ͕͙͢ʹ։ൃ͕Ͱ͖Δڥ͕͍ͬͯ·͢ɻ wϓϩδΣΫτͷHJUཧͷͨΊͷHJUJHOPSFHJUBUUSJCVUFTϑΝΠϧ w։ൃ͔ΒϓϩμΫτ·ͰΛҙࣝͨ͠Ϗϧυఆٛ w&DMJQTFΛ*%&Ͱ༻͢Δ߹ͷϓϩδΣΫτઃఆ w։ൃऀ͕͞·͟·ͳΤσΟλ*%&ͰҰ؏ͨ͠ίʔσΟϯάελΠϧΛఆٛ͠ɺ ҡ࣋͢ΔͨΊͷ&EJUPS$POpHઃఆ ͳͲͰ͢ɻ ޮྑ͍։ൃ
ӡ༻Λߟྀͨ͠ػೳΛΈࠐΈ͍ͨͷ͚ͩͲɺͲ͏͍͏͜ͱͨ͠Β͍͍ͩΖ͏ʁ ? ? ࠪূ ΞϓϦߏ ϩάग़ྗ ೝূ ηΩϡϦςΟ 3&45GVM"1*
ϖʔδϯά Τϥʔॲཧ ޮྑ͍։ൃ ӡ༻
ӡ༻ dependencies { : compile "org.springframework.boot:spring-boot-actuator" : } CVJMEHSBEMF
4QSJOH#PPU"DUVBUPSɺΞϓϦέʔγϣϯӡ༻Λָʹͯ͘͠ΕΔػೳΛఏڙͯ͘͠Ε·͢ɻ ɾ)551ΤϯυϙΠϯτͷՃ ɾϔϧενΣοΫ ɾϝτϦΫε ɾࠪূ
ӡ༻ ΤϯυϙΠϯτ આ໌ (&5BVUPDPOpH "VUP$POpHVSFͰ༗ޮʹͳ͍ͬͯΔͷɺແޮʹͳ͍ͬͯΔͷΛදࣔ͢Δ (&5CFBOT %*ίϯςφʹཧ͞Ε͍ͯΔ#FBOͷҰཡΛදࣔ͢Δ (&5FWO ڥมɺγεςϜϓϩύςΟͷҰཡΛදࣔ͢Δ
(&5DPOpHQSPQT !$POpHVSBUJPO1SPQFSUJFTͷ͍ͨϓϩύςΟͷҰཡΛදࣔ͢Δ (&5EVNQ εϨουμϯϓΛදࣔ͢Δ (&5IFBMUI ϔϧενΣοΫͷ݁ՌΛදࣔ͢Δ (&5JOGP JOGP͔Β࢝·ΔϓϩύςΟͷҰཡͳͲͷΞϓϦέʔγϣϯใΛදࣔ͢Δ (&5MPHpMF ϩάϑΝΠϧΛදࣔ͢Δ (&5NFUSJDT ϝτϦΫεΛදࣔ͢Δ (&5TIVUEPXO ΞϓϦέʔγϣϯΛఀࢭ͢Δ (&5USBDF )551ϦΫΤετͷϩάΛදࣔ͢Δ (&5qZXBZɺ (&5MJRVJCBTF 'MBXBZ·ͨ-JRVJCBTFͷσʔλϕʔεϚΠάϨʔγϣϯใΛදࣔ͢Δ (Spring徹底入門 p.624より) 4QSJOH#PPU"DUVBUPSʹΑΓ্هͷΑ͏ͳ)551ΤϯυϙΠϯτ͕Ճ͞Ε·͢ɻ +)JQTUFSͰɺ͜ΕΒͷػೳΛ׆༻ͨ͠ཧػೳ͕ॆ࣮͍ͯ͠·͢ɻ
ӡ༻ DPOpHQSPQTFWOΛ༻͍ͨઃఆը໘
ӡ༻ IFBMUIΛ༻͍ͨϔϧενΣοΫը໘
ӡ༻ NFUSJDTΛ༻͍ͨΞϓϦέʔγϣϯϝτϦΫεը໘
ӡ༻ ը໘͕༻ҙ͞Ε͍ͯͳ͍ͷʹ͍ͭͯɺBENJOϢʔβͰ(&5Λୟ͘͜ͱͰɺ ใΛදࣔͰ͖·͢ɻ CFBOTBVUPDPOpHͳͲͷใ։ൃʹཱͪ·͢ʂ
"HFOEB (FUUJOH4UBSU +)JQTUFSͱ -FBSOXJUI+)JQTUFS ·ͱΊ
·ͱΊ +)JQTUFSΛ͏͜ͱͰɺ͙͢ʹ࣮ӡ༻ʹ͑ΕΔ 8FCΞϓϦͷܗΛ༻ҙͰ͖·͢ʂ +)JQTUFS͕ग़ྗ͢Διʔείʔυʹ ચ࿅͞Ε࣮ͨͷώϯτ͕ࢄΒ͍ͬͯ·͢ʂ
(SFBU4QSJOH 'VO+)JQTUFS ʘ͢͝ʔ͍ʂͨͷ͠ʔʂʗ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ P ƅ˜ƅ P