Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[完全版] 新人研修や本では教えてくれないJava!

[完全版] 新人研修や本では教えてくれないJava!

JJUG CCC 2016 Fall

5dbaf4015e7f249ab21b195ced8e9e46?s=128

Masatoshi Tada

December 02, 2016
Tweet

Transcript

  1. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ৽ਓݚम΍ຊͰ͸ ڭ͑ͯ͘Εͳ͍+BWBʂ ʙϑϨʔϜϫʔΫͷ࢓૊Έͱ࣮຿ඞਢπʔϧΛֶ΅͏ʙ

    ג ΧαϨΞϧଟాਅහ ++6($$$'BMM 
  2. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ͜ͷηογϣϯʹ͍ͭͯ ▸ ৽ਓݚम΍ࢢൢॻ੶Ͱ͸ͳ͔ͳ͔঺հ͞Εͳ͍

    ͕ɺ։ൃݱ৔Ͱ͸ॏཁʹͳΔ಺༰ΛϨΫνϟʔ ▸ +BWBॳ৺ऀɺ͓Αͼࢦಋ໾ͷઌഐ͕ର৅ 2
  3. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ஫ҙ఺ ▸ ෼͔Γ΍͢͞Λ࠷ॏࢹͨͨ͠Ίɺٕज़తͳਖ਼֬

    ͞ʹ͚ܽΔ෦෼͕͋Δ͔΋͠Ε·ͤΜ ▸ ͓ؾ෇͖ͷ఺͕͋Ε͹ɺ
 5XJUUFS౳Ͱ༏͘͠ࢦఠͯ͠΍͍ͬͯͩ͘͞ 3
  4. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 େࣄͳ͜ͱͳͷͰճݴ͍·͢ ▸༏͘͠
 ࢦఠͯ͠΍͍ͬͯͩ͘͞

    4
  5. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ᶃ ৽ਓݚमͰڭ͑Δ+BWBɺڭ͑ͳ͍+BWB ᶄ

    ϥΠϒϥϦΛ؆୯ʹ࢖͓͏ʂϏϧυπʔϧ.BWFO ᶅ 8FCࡾछͷਆثʂ8FCϑϨʔϜϫʔΫɾ
 %*ίϯςφɾ03Ϛούʔ ᶆ ϑϨʔϜϫʔΫͷ࢓૊ΈΛ஌Ζ͏ʂ
 ϦϑϨΫγϣϯͱΞϊςʔγϣϯ ᶇ τϥϒϧγϡʔςΟϯάʹඞਢʂ
 ϩΪϯάϥΠϒϥϦ-PHCBDL ᶈ ͜Ε͔ΒͲ͏ֶश͢Δ͔ʁ 5
  6. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ࣗݾ঺հ ▸ ଟాਅහʢ!TVLF@NBTBʣ

    ▸ ݚमτϨʔφʔ!ΧαϨΞϧ ▸ ઐ໳ɿ+BWB&&4QSJOH4XJGU ▸ (MBTT'JTI6TFS(SPVQ+BQBOӡӦϝϯόʔ ▸ +BWB&&(VBSEJBOT ▸ ++6($$$ग़৔ɿճ࿈ଓճ໨ 6
  7. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ᶃ ৽ਓݚमͰڭ͑Δ+BWBɺڭ͑ͳ͍+BWB ᶄ

    ϥΠϒϥϦΛ؆୯ʹ࢖͓͏ʂϏϧυπʔϧ.BWFO ᶅ 8FCࡾछͷਆثʂ8FCϑϨʔϜϫʔΫɾ
 %*ίϯςφɾ03Ϛούʔ ᶆ ϑϨʔϜϫʔΫͷ࢓૊ΈΛ஌Ζ͏ʂ
 ϦϑϨΫγϣϯͱΞϊςʔγϣϯ ᶇ τϥϒϧγϡʔςΟϯάʹඞਢʂ
 ϩΪϯάϥΠϒϥϦ-PHCBDL ᶈ ͜Ε͔ΒͲ͏ֶश͢Δ͔ʁ 7
  8. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 Ұൠతͳ+BWB৽ਓݚम લ൒ ᶃ

    ίϯϐϡʔλʔͷجૅʢʙ೔ؒʣ ▸ ίϯϐϡʔλʔͷେػೳɺωοτϫʔΫɺ%#42- ᶄ ϓϩάϥϛϯάͷجૅʢʙ೔ؒʣ ▸ ม਺ɺ৚݅෼ذɺ܁Γฦ͠ɺ഑ྻɺϝιου ᶅ ΦϒδΣΫτࢦ޲ʢʙ೔ؒʣ ▸ ΫϥεɺίϯετϥΫλɺΦʔόʔϩʔυɺܧঝɺΞΫηεम ০ࢠɺΦʔόʔϥΠυɺந৅ΫϥεɺΠϯλϑΣʔε 8
  9. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 Ұൠతͳ+BWB৽ਓݚम ޙ൒ ᶆ

    ඪ४"1*ʢʙ೔ؒʣ ▸ 4USJOHɺϥούʔΫϥεɺ%BUFɺ4JNQMF%BUF'PSNBUɺ
 'JMF3FBEFS8SJUFSɺ"SSBZ-JTUɺ)BTI.BQ ᶇ 8FCΞϓϦέʔγϣϯʢʙ೔ؒʣ ▸ αʔϒϨοτɺ+41ɺ+%#$ ᶈ ։ൃԋशʢʙ೔ؒʣ ‣ ʙਓͷάϧʔϓͰͷٖࣅϓϩδΣΫτ 9
  10. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ৽ਓݚमͰ͸ڭΘΒͳ͍ ͜ͱ͕ଟ͍ +BWB

    ▸ ྻڍܕ &OVN  ▸ ֦ுGPSจ ▸ USZXJUISFTPVSDFT ▸ ϥϜμࣜ4USFBN"1* ▸ %BUFBOE5JNF"1* 10 Java SE 5Ҏ߱ͷ৽ػೳ͸ ΄ͱΜͲशΘͳ͍ʂ ※ݱࡏ͸Java SE 8͕࠷৽ ※δΣωϦΫεͱΦʔτϘΫγϯά͸ ɹश͏͜ͱ͕ଟ͍
  11. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ৽ਓݚमͰ͸ڭΘΒͳ͍ ͜ͱ͕ଟ͍ 8FC

    ▸ +45- ▸ )551ͷৄࡉ ▸ εςʔλείʔυɺϔομʔɺ$PPLJFͳͲ ▸ σʔλιʔε ▸ !8FC4FSWMFUΞϊςʔγϣϯ 11 ΧϦΩϡϥϜ͸ 15೥͘Β͍มΘͬͯͳ͍
  12. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ͦ΋ͦ΋+BWB͸ྔ͕ଟ͍ʂ ▸ ʙϲ݄ؒͷ৽ਓݚमͰશ෦͸ڭ͖͑Εͳ͍

    ▸ ݚमҎ্ͷࣗݾֶश͸ඞਢ ▸ ྑॻ͸ଟ͍ͷͰࣗݾֶश͸Մೳʂ ▸ ࠷ޙʹ঺հ͠·͢ 12
  13. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ᶃ ৽ਓݚमͰڭ͑Δ+BWBɺڭ͑ͳ͍+BWB ᶄ

    ϥΠϒϥϦΛ؆୯ʹ࢖͓͏ʂϏϧυπʔϧ.BWFO ᶅ 8FCࡾछͷਆثʂ8FCϑϨʔϜϫʔΫɾ
 %*ίϯςφɾ03Ϛούʔ ᶆ ϑϨʔϜϫʔΫͷ࢓૊ΈΛ஌Ζ͏ʂ
 ϦϑϨΫγϣϯͱΞϊςʔγϣϯ ᶇ τϥϒϧγϡʔςΟϯάʹඞਢʂ
 ϩΪϯάϥΠϒϥϦ-PHCBDL ᶈ ͜Ε͔ΒͲ͏ֶश͢Δ͔ʁ 13
  14. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 +BWB͸Φʔϓϯιʔε͕ॆ࣮ʂ ▸ ੈքதͷਓ͕ϥΠϒϥϦΛ࡞੒ɾެ։͍ͯ͠Δ

    14 ͜Μͳͷ࡞ͬͨΑʂ ΈΜͳ࢖ͬͯʂ ͜Μͳͷ࡞ͬͨΑʂ ΈΜͳ࢖ͬͯʂ ͜Μͳͷ࡞ͬͨΑʂ ΈΜͳ࢖ͬͯʂ ͜Μͳͷ࡞ͬͨΑʂ ΈΜͳ࢖ͬͯʂ
  15. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ໰୊఺ɿͲ͏΍ͬͯϥΠϒϥϦΛूΊΔʁ ▸ ֤ϥΠϒϥϦͷެࣜαΠτʹΞΫηε͢Δ


    ˠݸ਺͕ଟ͍ͱେม 15 ϥΠϒϥϦAͷ ެࣜαΠτ ϥΠϒϥϦBͷ ެࣜαΠτ ϥΠϒϥϦCͷ ެࣜαΠτ ϥΠϒϥϦDͷ ެࣜαΠτ ϥΠϒϥϦEͷ ެࣜαΠτ
  16. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ໰୊఺ɿґଘੑ͸Ͳ͏΍ͬͯղܾ͢Δʁ ▸ ͋ΔϥΠϒϥϦ"͕ɺผͷϥΠϒϥϦ#ͱ$Λ࢖ͬ

    ͍ͯͯɺ#͸ߋʹ%ͱ&Λ࢖͍ͬͯΔ
 ˠશ෦ௐ΂ͳ͖Ό͍͚ͳ͍ͷʁ 16 ϥΠϒϥϦA ϥΠϒϥϦB ϥΠϒϥϦC ϥΠϒϥϦD ϥΠϒϥϦE
  17. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ໰୊఺ɿόʔδϣϯΞοϓͲ͏͢Δʁ ▸ ϥΠϒϥϦ"ͷόʔδϣϯΛ্͛Δͱɺґଘ͢Δ

    ϥΠϒϥϦ΋ҶͮΔࣜʹ্͛ͳ͚Ε͹ͳΒͳ͍
 ˠຖճɺಉ͡ௐࠪΛ͢Δͷʁ 17 ϥΠϒϥϦA 1.0->1.1 ϥΠϒϥϦB 2.1->2.3 ϥΠϒϥϦC 1.1.1->1.1.2 ϥΠϒϥϦD 4.3.0->5.0.0 ϥΠϒϥϦE 2.2.2->2.2.2
  18. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ͦ͜Ͱ.BWFOʂ ▸ 9.-ʹඞཁͳϥΠϒϥϦΛॻ͚ͩ͘Ͱ

    ▸ ඞཁͳϥΠϒϥϦͷμ΢ϯϩʔυ΍ɺΫϥεύε΁ͷ௥ Ճ͕Ͱ͖Δʂ ▸ ґଘϥΠϒϥϦΛҶͮΔࣜʹऔಘͰ͖Δʂ ▸ όʔδϣϯΞοϓ͸ઃఆϑΝΠϧΛॻ͖׵͑Δ͚ͩʂ ▸ ݱࡏͰ͸ɺ+BWBϏϧυπʔϧͷσϑΝΫτελϯ μʔυ 18
  19. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 .BWFO$FOUSBM3FQPTJUPSZ ▸ Πϯλʔωοτ্ͷɺ΄ͱ

    ΜͲͷΦʔϓϯιʔεϥΠ ϒϥϦ͕ू·͍ͬͯΔ৔ॴ ▸ 9.-ʹࢦఆͨ͠ϥΠϒϥϦ ͸ɺ͔͜͜Βμ΢ϯϩʔυ ͞ΕΔ ▸ IUUQTFBSDINBWFOPSH Ͱݕࡧ΋Մೳ 19 ϥΠϒϥϦ ϥΠϒϥϦ ϥΠϒϥϦ ϥΠϒϥϦ ϥΠϒϥϦ
  20. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 .BWFOͷΠϯετʔϧ ᶃ IUUQTNBWFOBQBDIFPSHEPXOMPBEDHJ


    ͔Β;*1Λμ΢ϯϩʔυˠద౰ͳϑΥϧμʹల։ ᶄ ల։ઌϑΥϧμBQBDIFNBWFOCJOΛ؀ ڥม਺1"5)ʹ௥Ճ 20
  21. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 *%&Λ࢖͏ͱʁ ▸ *%&ʹ͸ݩ͔Β.BWFO͕಺แ͞Ε͍ͯΔ

    ▸ ͨͩ͠ɺίϚϯυϓϩϯϓτ͔Β.BWFOΛ࢖͏ ͜ͱ΋ଟ͍ ▸ ͳΔ΂͘ɺݸผʹ΋Πϯετʔϧ͠·͠ΐ͏ 21
  22. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 .BWFOϓϩδΣΫτͷ࡞੒ ᶃ<ϑΝΠϧ><৽ن>
 <ͦͷଞ>


    <.BWFO>
 <.BWFOϓϩδΣΫτ>
 <࣍΁> ᶄ<γϯϓϧͳϓϩδΣΫτ ͷ࡞੒>ʹνΣοΫ
 <࣍΁> 22
  23. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 .BWFOϓϩδΣΫτͷ࡞੒ ᶅ<άϧʔϓ*E>ͱ<ΞʔςΟ ϑΝΫτ*E>ʹద౰ʹೖྗ


    <ύοέʔδϯά>͸8FC ͳΒ<XBS>ɺͦΕҎ֎ͳ Β<KBS>
 <׬ྃ> 23
  24. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 QPNYNMͷฤू ▸ ͜͜ʹඞཁͳϥΠϒϥϦΛهड़͢Δ

    24 <?xml version="1.0" encoding="UTF-8"?> <project …> <!— தུ —> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>4.3.4.RELEASE</version> <scope>compile</scope> </dependency> </dependencies>
  25. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 QPNYNMͷฤू ▸ ඞཁͳϥΠϒϥϦ͕ҶͮΔࣜʹμ΢ϯϩʔυ͞

    ΕΔ 25
  26. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 EFQFOEFODZͷࢠཁૉ 26 ࢠཁૉ໊

    ҙຯ groupId ϥΠϒϥϦΛ࡞੒͍ͯ͠Δஂମ໊ artifactId ϥΠϒϥϦ໊ version ϥΠϒϥϦͷόʔδϣϯ scope ʢޙड़ʣ
  27. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 EFQFOEFODZͷॻ͖ํΛௐ΂Δํ๏ ᶃIUUQTFBSDINBWFOPSHͰݕࡧ
 ˠόʔδϣϯ൪߸ΛΫϦοΫ

    ▸ <BMM>ϦϯΫΛΫϦοΫ͢ΔͱɺશόʔδϣϯͷҰཡ͕ݟΕΔ 27
  28. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 EFQFOEFODZͷॻ͖ํΛௐ΂Δํ๏ ᶄ9.-͕ॻ͍ͯ͋ΔͷͰɺ ͜ΕΛίϐϖ͢Ε͹0,

    ▸ खॻ͖͢Δͱϛε͠·͢ 28
  29. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ϥΠϒϥϦͷอଘ৔ॴ ▸ Ұ౓μ΢ϯϩʔυͨ͠ϥΠϒϥϦ͸ɺԼهͷϑΥ

    ϧμʹอଘ͞ΕΔ ▸ 8JOEPXTˠ$a6TFSTaϢʔβʔ໊aNaSFQPTJUPSZ ▸ NBD04ˠ6TFSTϢʔβʔ໊NSFQPTJUPSZ 29
  30. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 +"3΁ͷύοέʔδϯά ▸ ίϚϯυϓϩϯϓτͰQPNYNM

    ͕͋ΔϑΥϧμʹҠಈ
 ˠmvn packageίϚϯυΛ࣮ߦ
 ˠUBSHFUϑΥϧμ͕࡞੒͞Εɺ
 ɹͦͷதʹ+"3ϑΝΠϧ͕
 ɹ࡞੒͞ΕΔ ▸ લʹ࡞੒ͨ͠+"3ͳͲΛ࡟আͯ͠ ࠶ύοέʔδϯά͍ͨ͠৔߹͸ mvn clean packageΛ࣮ߦ 30
  31. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 .BWFOϓϩδΣΫτͷϑΥϧμߏ଄ 31 ϓϩδΣΫτ

    pom.xml src main test java resources java resources ιʔείʔυ ઃఆϑΝΠϧ ςετ༻ιʔείʔυ ςετ༻ઃఆϑΝΠϧ
  32. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ϑΥϧμߏ଄ͱ+"3ύοέʔδϯά 32 ͚͕ͩ͜͜JARʹ

    ؚ·ΕΔ
  33. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 $ jar -tf

    target/maven-sample-1.0-SNAPSHOT.jar com/example/entity/Employee.class com/example/repository/EmployeeRepository.class jdbc.properties ϑΥϧμߏ଄ͱ+"3ύοέʔδϯά 33 src/main/java ͷத਎ src/main/resources ͷத਎ JARϑΝΠϧͷத਎ΛݟΔίϚϯυ ※Ұ෦লུ͍ͯ͠·͢
  34. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 8FCΞϓϦέʔγϣϯͷ৔߹ ▸ QPNYNMͰԼهͷΑ͏ʹࢦఆ

    34 <?xml version="1.0" encoding="UTF-8"?> <project …> <groupId>com.example</groupId> <artifactId>maven-sample</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <!— লུ —>
  35. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 8FCΞϓϦέʔγϣϯͷϑΥϧμߏ଄ 35 src

    main test java resources java resources ιʔείʔυ ઃఆϑΝΠϧ ςετ༻ιʔείʔυ ςετ༻ઃఆϑΝΠϧ webapp WEB-INF web.xml JSPɺHTMLͳͲ ※εϖʔεͷ౎߹্ɺϓϩδΣΫτϑΥϧμͱpom.xml͸লུ͍ͯ͠·͢
  36. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ϑΥϧμߏ଄ͱ8"3ύοέʔδϯά 36 WEB-INF/classes΁

    WAR௚Լ΁
  37. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 $ jar -tf

    target/maven-sample-1.0-SNAPSHOT.war index.jsp WEB-INF/web.xml WEB-INF/classes/com/example/entity/Employee.class WEB-INF/classes/com/example/repository/EmployeeRepository.class WEB-INF/classes/jdbc.properties WEB-INF/lib/commons-logging-1.2.jar WEB-INF/lib/spring-beans-4.3.4.RELEASE.jar WEB-INF/lib/spring-core-4.3.4.RELEASE.jar WEB-INF/lib/spring-jdbc-4.3.4.RELEASE.jar WEB-INF/lib/spring-tx-4.3.4.RELEASE.jar ϑΥϧμߏ଄ͱ8"3ύοέʔδϯά 37 src/main/java, src/main/resources pom.xmlʹࢦఆͨ͠ϥΠϒϥϦ ʢҶͮΔࣜʹඞཁͳ΋ͷ΋ؚΉʣ ※Ұ෦লུ͍ͯ͠·͢ src/main/webapp
  38. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 TDPQFͱ͸ 38 <dependency>

    <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>4.3.4.RELEASE</version> <scope>compile</scope> </dependency> ▸ ͦͷϥΠϒϥϦ͕ ▸ ͲΜͳ࣌ʹΫϥεύεʹ௥Ճ͞ΕΔͷ͔ʁ ▸ 8"3ʹؚ·ΕΔͷ͔ʁʢʹ8&#*/'MJCʹೖΔͷ͔ʣ
  39. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 TDPQF͸ओʹछྨ 39 scope໊

    ίϯύΠϧ ࣮ߦ ςετ WARʹؚ·ΕΔ compile (σϑΥϧτ) ̋ ̋ ̋ ̋ provided ̋ × × × runtime × ̋ ̋ ̋ test × × ̋ × ※΋͏1ͭʮsystemʯͱ͍͏scope͕͋Γ·͕͢ɺ͋·Γଟ༻͠ͳ͍ͷͰࠓճ͸આ໌͠·ͤΜ
  40. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 TDPQFͷܾΊํ ▸ 8FCΞϓϦέʔγϣϯͷ৔߹

    ▸ QSPWJEFEˠ"1αʔόʔʹؚ·Ε͍ͯΔ΋ͷʢαʔϒ Ϩοτ"1*ͳͲʣ ▸ DPNQJMFˠ"1αʔόʔʹؚ·Ε͍ͯͳ͍΋ͷ ▸ UFTUˠςετ࣌ʹͷΈඞཁͳ΋ͷ ▸ SVOUJNFˠ΄΅࢖Θͳ͍ 40
  41. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ຊষͷ·ͱΊ ▸ QPNYNMʹEFQFOEFODZΛॻ͘ʂ

    ▸ EFQFOEFODZ͸.BWFO$FOUSBM3FQPTJUPSZͰ ݕࡧͯ͠ίϐʔʂ ▸ ϑΥϧμߏ଄͕ܾ·͍ͬͯΔʂ ▸ छྨͷείʔϓΛద੾ʹࢦఆ͠Α͏ʂ 41
  42. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ᶃ ৽ਓݚमͰڭ͑Δ+BWBɺڭ͑ͳ͍+BWB ᶄ

    ϥΠϒϥϦΛ؆୯ʹ࢖͓͏ʂϏϧυπʔϧ.BWFO ᶅ 8FCࡾछͷਆثʂ8FCϑϨʔϜϫʔΫɾ
 %*ίϯςφɾ03Ϛούʔ ᶆ ϑϨʔϜϫʔΫͷ࢓૊ΈΛ஌Ζ͏ʂ
 ϦϑϨΫγϣϯͱΞϊςʔγϣϯ ᶇ τϥϒϧγϡʔςΟϯάʹඞਢʂ
 ϩΪϯάϥΠϒϥϦ-PHCBDL ᶈ ͜Ε͔ΒͲ͏ֶश͢Δ͔ʁ 42
  43. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ৽ਓݚमఆ൪ͷ࠷ऴ՝୊ ▸ αʔϒϨοτɾ+41ɾ+%#$Ͱɺ


    "NB[POͷΑ͏ͳγϣοϐϯάαΠτΛ։ൃ ᶃϩάΠϯɾϩάΞ΢τ ᶄ঎඼ͷݕࡧ ᶅങ͍෺Χΰ΁ͷ௥Ճ ᶆ஫จొ࿥ 43
  44. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 .7$Ϟσϧ ▸ ྫɿ঎඼ͷݕࡧ

    44 ݕࡧΩʔϫʔυ ೖྗը໘ ʢJSPʣ ݕࡧ݁Ռ දࣔը໘ ʢJSPʣ ঎඼ݕࡧ ίϯτϩʔϥʔ ʢαʔϒϨοτʣ ঎඼DAO ʢJavaʣ ঎඼ ΤϯςΟςΟ ʢJavaʣ View Controller Model DB
  45. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 αʔϒϨοτɾ+41ͷ໰୊఺ ▸ .ɾ7ɾ$͕ࠞࡏ͢Δ͜ͱ͕͋Δ

    ▸ ྫɿαʔϒϨοτ͸7JFXʹ΋ͳΕΔʢPVUQSJOUMO ʣ ▸ ྫɿ+41͸%#ΞΫηε΋Ͱ͖ΔʢεΫϦϓτϨοτʣ ▸ ೖྗνΣοΫػೳ͕ແ͍ ▸ αʔϒϨοτͷ୯ମςετ͕ࠔ೉ 45
  46. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 +%#$ͷ໰୊఺ ▸ ࣅͨΑ͏ͳίʔυΛຖճ

    ॻ͔ͳ͚Ε͹ͳΒͳ͍ ▸ ίωΫγϣϯऔಘɺ
 εςʔτϝϯτऔಘɺ
 ύϥϝʔλࢦఆɺ
 ݁Ռηοτͷऔಘɺ
 ৚݅෼ذͯ͠ɺ
 ֤ྻ͔Β஋औΓग़͠ɺ
 ΤϯςΟςΟʹ୅ೖɺɾɾɾ 46 public Employee findById(Integer id) { Employee employee = null; // ໭Γ஋ String sql = "SELECT name, department_id," + " joined_date FROM employee WHERE id = ?"; try (Connection con = DriverManager .getConnection(URL, USER, PASSWORD); PreparedStatement ps = con.prepareStatement(sql)) { ps.setInt(1, id); ResultSet rs = ps.executeQuery(); if (rs.next()) { String name = rs.getString("name"); int departmentId = rs.getInt("department_id"); Date joinedDate = rs.getDate("joined_date"); employee = new Employee(); employee.setId(id); employee.setName(name); employee.setDepartmentId(departmentId); employee.setJoinedDate(joinedDate); } } catch (SQLException e) { // ຊདྷ͸ϩάग़ྗ΍ྫ֎ͷ࠶εϩʔΛߦ͏ e.printStackTrace(); } return employee; } ※ ※ʮϘΠϥʔϓϨʔτίʔυʯͱݺ͹ΕΔ
  47. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ͦ͜Ͱछͷਆثʂ ᶃ8FCϑϨʔϜϫʔΫ ▸

    .7$ΛΩονϦ෼͚ΔʂೖྗνΣοΫػೳͱͷ࿈ܞʂ ᶄ%*ίϯςφ ▸ ୯ମςετΛ༰қʹ͢Δʂ ᶅ03Ϛούʔ ▸ %#ΞΫηεΛ؆ܿʹॻ͚Δʂ 47
  48. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 8FCϑϨʔϜϫʔΫͱ͸ʁ ▸ ϑϨʔϜϫʔΫʹ࿮૊Έ

    ▸ Ϗϡʔͱͷ࿈ܞ͓ΑͼίϯτϩʔϥʔΛఏڙ͢Δ ▸ ίϯτϩʔϥʔ಺ʹϏϡʔͷग़ྗ͸ॻ͚ͳ͍ʂ 48 ೖྗը໘ ݁Ռը໘ ίϯτϩʔϥʔ DAO ΤϯςΟ ςΟ DB WebϑϨʔϜϫʔΫͷൣғ
  49. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 8FCϑϨʔϜϫʔΫͷେ·͔ͳ࢓૊Έ ▸ ϑϩϯτίϯτϩʔϥʔ

    ͱݺ͹ΕΔαʔϒϨοτ ͕શͯͷϦΫΤετΛड ͚औΓɺ֤ίϯτϩʔϥʔ ʹॲཧΛৼΓ෼͚Δ 49 ϑϩϯτ ίϯτϩʔϥʔ ʢαʔϒϨοτʣ ίϯτ ϩʔϥʔ ίϯτ ϩʔϥʔ ίϯτ ϩʔϥʔ ϦΫΤετ ※ϑϨʔϜϫʔΫ ಺ͷΫϥε ϦϑϨΫγϣϯΛ ࢖͍ͬͯΔʢޙड़ʣ
  50. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 छྨͷ8FCϑϨʔϜϫʔΫ ᶃΞΫγϣϯϕʔε
 ϑϨʔϜϫʔΫ

    ▸ αʔϒϨοτɾ+41ͱ ΄΅ಉ͡ײ֮Ͱϓϩά ϥϜΛ࡞੒͢Δ ▸ +BWBͰ͸ଟ਺೿ ▸ 4QSJOH.7$ɺ4USVUT ͕୅දྫ 50 ೖྗը໘ ݁Ռը໘ ίϯτϩʔϥʔ
  51. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 छྨͷ8FCϑϨʔϜϫʔΫ ᶄίϯϙʔωϯτϕʔε
 ϑϨʔϜϫʔΫ

    ▸ /&5΍"OESPJEͳͲ(6* ΞϓϦͱಉ͡ײ֮Ͱϓ ϩάϥϜΛ࡞੒͢Δ ▸ +BWBͰ͸গ਺೿ ▸ +4'͕୅දྫ 51 ೖྗը໘ ೖྗ߲໨1 ೖྗ߲໨2 ೖྗ߲໨3 όοΩϯά Ϗʔϯ String input1; String input2; String input3;
  52. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ೖྗνΣοΫػೳ ▸ ΄΅શͯͷϑϨʔϜϫʔ

    ΫͰɺೖྗνΣοΫػ ೳ͕ఏڙ͞Ε͍ͯΔ ▸ ӈͷίʔυ͸
 #FBO7BMJEBUJPOͷྫ ▸ 4QSJOH.7$Ͱ΋+4' Ͱ΋࢖͑Δ 52 public class InputForm { @NotNull @Size(min = 1, max = 10) private String input1; @NotNull @Max(99) private Integer number; // setter/getterলུ }
  53. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 Ϗϡʔ͸ʁ ▸ 4QSJOH.7$΍4USVUTͰ͸+41͕σϑΥϧτ


    ˠϏϡʔʹϩδοΫ͕ࠞࡏͰ͖Δ໰୊
 ˠ࠷ۙͰ͸୅ΘΓʹ5IZNFMFBG͕Α͘࢖ΘΕΔ ▸ +4'Ͱ͸طʹ+41͕ඇਪ঑
 ˠ'BDFMFUTͱ͍͏ผͷϏϡʔٕज़Λ࢖͍ͬͯΔ 53
  54. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 /PNPSF+41 ▸ ࠷ۙͰ͸ɺ+41͸ੵۃతʹ࠾༻͞Εͳ͍܏޲

    ▸ ϏϡʔͱϩδοΫ͕ࠞࡏͰ͖ͯ͠·͏ ▸ σϑΥϧτͰ͸ΤεέʔϓॲཧΛ͠ͳ͍ͨΊɺ
 ΫϩεαΠτεΫϦϓςΟϯά੬ऑੑ͕ى͖΍͍͢ ▸ ग़ྗ͢Δ෦෼͸શͯDPVUͰॻ͔ͳ͍ͱ੬ऑੑʹͳΔ ▸ ৄࡉ͸ʮΫϩεαΠτεΫϦϓςΟϯάʯͰάάͬͯͩ͘ ͍͞ 54
  55. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 03Ϛούʔͱ͸ʁ ▸ %#ΞΫηεΛ؆୯ʹॻ͚ΔϥΠϒϥϦ

    ▸ +%#$Ͱ਺ेߦͷϓϩάϥϜ͕ɺ΋ͷͷ਺ߦʹʂ ▸ େ͖͘෼͚ͯλΠϓɻϝϦοτɾσϝϦοτΛߟ͑ͯ࠾༻͠·͠ΐ͏ʂ 55 ೖྗը໘ ݁Ռը໘ ίϯτϩʔϥʔ DAO ΤϯςΟ ςΟ DB ORϚούʔͷൣғ
  56. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 λΠϓᶃڱٛͷ03Ϛούʔ ▸ ࠷΋ϓϩάϥϜ͕୹͘ॻ͚Δ

    ▸ 42-͢Βॻ͔ͳ͍ ▸ ͨͩ͠ɺͦͷ෼͚ͩ։ൃऀ͔Β ݟ͑ͳ͍෦෼΋ଟ͘ɺϋϚΓͲ ͜Ζ͸ଟ͍ ▸ Ұൠతʹɺਖ਼نԽ͞Ε͍ͯͳ͍ %#ʹ͸޲͔ͳ͍ͱ͞Ε͍ͯΔ ▸ ୅දྫɿ+1"ɺ)JCFSOBUF 56 // JPAͷྫ EntityManager em = …; Employee employee = em.find(Employee.class, 101); ϦϑϨΫγϣϯΛ ࢖͍ͬͯΔʢޙड़ʣ
  57. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 λΠϓᶄ42-Ϛούʔ ▸ 42-ΛςΩετϑΝΠϧ΍

    9.-ʹॻ͘ ▸ ෳࡶͳ+0*/ɺ෭໰͍߹Θ ͤɺΠϯσοΫεͷ׆༻΋ Մೳ ▸ ࡞੒͢΂͖ϑΝΠϧ͸ɺڱٛ ͷ03ϚούʔΑΓଟ͘ͳΔ ▸ ୅දྫɿ.Z#BUJTɺ%PNB 57 EmployeeDao dao = …; Employee employee = dao.findById(101); // Domaͷྫ @Dao public interface EmployeeDao { Employee findById(int id); } SELECT id, name, joined_date, department_id FROM employee WHERE id = /*id*/999
  58. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 λΠϓᶅλΠϓηʔϑܕ ▸ Ϋϥε΍ϝιουΛར༻

    ͯ͠42-Λ૊ΈཱͯΔ ▸ จࣈྻΛॻ͔ͳ͍ͨΊɺه ड़ϛεʹΑΔ࣮ߦ࣌ྫ֎͕ গͳ͘ͳΔ ▸ هड़ྔ͸͔ͳΓ૿͑Δ ▸ ୅දྫɿ2VFSZ%4-ɺ K002ɺ%#'MVUF 58 // QueryDSLͷྫ QCustomer c = new QCustomer("c"); SQLTemplates dialect = …; SQLQuery<?> query = …; List<String> lastNames = query .select(c.lastName) .from(c) .where(c.firstName.eq("Bob")) .fetch(); https://github.com/querydsl/querydsl/tree/master/querydsl-sql ͔ΒҾ༻
  59. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 %*ίϯςφͱ͸ʁ ▸ ίϯτϩʔϥʔͱ%"0ʢ·ͨ͸Ϗδωεϩδο

    Ϋʣͷ઀ଓΛ୲౰͢Δ 59 ೖྗը໘ ݁Ռը໘ ίϯτϩʔϥʔ DAO ΤϯςΟ ςΟ DB DIίϯςφͷൣғ
  60. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 %*ͱ͸ʁ 60 //

    DAOΠϯλϑΣʔε public interface EmployeeDao { Employee findById(int id); } // DAOΠϯλϑΣʔεͷ࣮૷Ϋϥε public class EmployeeDaoImpl implements EmployeeDao { @Override public Employee findById(int id) { // ORϚούʔͰDBΞΫηε͢Δ } }
  61. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 %*ͱ͸ʁ 61 //

    DIΛ࢖͍ͬͯͳ͍ίϯτϩʔϥʔΫϥε public class EmployeeController { public String findById(int id) { EmployeeDao dao = new EmployeeDaoImpl(); Employee employee = dao.findById(id); // ը໘ʹϑΥϫʔυ } }
  62. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 %*ͱ͸ʁ 62 //

    DIΛ࢖͍ͬͯΔίϯτϩʔϥʔΫϥε public class EmployeeController { @Inject EmployeeDao dao; public String findById(int id) { Employee employee = dao.findById(id); // ը໘ʹϑΥϫʔυ } } EmployeeDaoImplͷ Πϯελϯε͕ ࣗಈతʹ୅ೖ͞ΕΔ ϦϑϨΫγϣϯΛ ࢖͍ͬͯΔʢޙड़ʣ
  63. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 %*ͷԿ͕خ͍͔͠ʁ ▸ ୯ମςετ͕΍Γ΍͘͢ͳΔʂ

    ▸ ίϯτϩʔϥʔΫϥεͷ୯ମςετ࣌ʹɺ
 &NQMPZFF%BPͷԾͷΫϥεʢʹελϒɺϞοΫʣʹ ࠩ͠ସ͑͠΍͘͢ͳΔ ▸ %*Λ࢖͍ͬͯͳ͍৔߹ɺඞͣ&NQMPZFF%BP*NQMΫϥ ε͕ඞཁʹͳΔͨΊɺࠩ͠ସ͑͸ࠔ೉ 63
  64. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ԾͷΫϥεΛར༻ͨ͠୯ମςετ 64 //

    DAOΠϯλϑΣʔεͷελϒʢςετ༻ͷԾΫϥεʣ public class StubEmployeeDao implements EmployeeDao { @Override public Employee findById(int id) { // ୯७ͳݻఆ஋Λฦ͢ͷΈ Employee emp = new Employee(); emp.setId(id); emp.setName("ࢁాଠ࿠"); emp.setDepartmentId(10); emp.setJoinedDate(LocalDate.of(2016, 12, 3)); return emp; } }
  65. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ελϒΛར༻ͨ͠ίϯτϩʔϥʔͷ୯ମςετ 65 //

    JUnitͰͷྫ public class EmployeeControllerTest { @Test public void test_findById() { EmployeeController controller = new EmployeeController(); // DAOϑΟʔϧυʹελϒΛ୅ೖ controller.dao = new StubEmployeeDao(); // ίϯτϩʔϥʔϝιουͷςετ String viewName = controller.findById(101); assertThat(viewName, is("index")); } }
  66. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ຊ൪؀ڥͰ͸ʁ ▸ &NQMPZFF%BP*NQMͷΠϯελϯε͕ࣗಈతʹ୅

    ೖ͞ΕΔ ▸ %FQFOEFODZ*OKFDUJPOʢґଘੑͷ஫ೖʣ
 ʹΠϯελϯεͷ୅ೖ 66
  67. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 %*ίϯςφͷ΋ͬͱৄ͍͜͠ͱ͸ ▸ ͜ͷ෦԰ͷ࣍ͷηογϣϯ


    ʮ4QSJOH͸Ͳ͏΍ͬͯ%*͍ͯ͠Δͷ͔ʯ
 ΁Ͳ͏ͧʂ 67
  68. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ຊষͷ·ͱΊ ▸ 8FCϑϨʔϜϫʔΫͰ.7$ΛΩονϦ෼͚Δʂ

    ▸ ͨͩ͠ɺ+41͸ଔۀ͠Α͏ ▸ 03ϚούʔͰ%#ΞΫηεΛ؆ܿʹॻ͘ʂ ▸ λΠϓͷͲΕ͕ࣗ෼ͷϓϩδΣΫτʹ߹͏͔ߟ͑Α͏ ▸ %*ίϯςφͱΠϯλϑΣʔεΛ׆༻ͯ͠ɺ
 ςετ͠΍͍͢ߏ଄Λ࡞Δʂ 68
  69. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ᶃ ৽ਓݚमͰڭ͑Δ+BWBɺڭ͑ͳ͍+BWB ᶄ

    ϥΠϒϥϦΛ؆୯ʹ࢖͓͏ʂϏϧυπʔϧ.BWFO ᶅ 8FCࡾछͷਆثʂ8FCϑϨʔϜϫʔΫɾ
 %*ίϯςφɾ03Ϛούʔ ᶆ ϑϨʔϜϫʔΫͷ࢓૊ΈΛ஌Ζ͏ʂ
 ϦϑϨΫγϣϯͱΞϊςʔγϣϯ ᶇ τϥϒϧγϡʔςΟϯάʹඞਢʂ
 ϩΪϯάϥΠϒϥϦ-PHCBDL ᶈ ͜Ε͔ΒͲ͏ֶश͢Δ͔ʁ 69
  70. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 αʔϒϨοτ͸ͳͥಈ͘ʁ ▸ αʔϒϨοτΫϥεΛ࡞ͬͯɺXFCYNMʹΫϥε໊

    Λॻ͚ͩ͘ ▸ NBJO ϝιου͸࡞Βͳ͍ 70
  71. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ΞϓϦέʔγϣϯαʔόʔ͕΍͍ͬͯΔ͜ͱ ▸ ΞϓϦέʔγϣϯαʔόʔͷىಈࣗମ͕


    NBJO ϝιουͷ࣮ߦͱߟ͑Ε͹ྑ͍ ▸ ΞϓϦέʔγϣϯαʔόʔ͸ɺ ᶃXFCYNMΛಡΈࠐΜͰαʔϒϨοτΫϥε໊Λऔಘ͢Δ ᶄΫϥε໊͔ΒαʔϒϨοτͷΠϯελϯεΛੜ੒͢Δ ᶅΠϯελϯεͷEP(FU EP1PTU Λ࣮ߦ͢Δ 71
  72. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ΞϓϦέʔγϣϯαʔόʔ͕΍͍ͬͯΔ͜ͱ 72 †startup.bat

    ≒mainϝιουىಈ <servlet> <servlet-name>HelloServlet</servlet-name> <servlet-class>com.example.HelloServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloServlet</servlet-name> <url-pattern>/hello</url-pattern> </servlet-mapping> ᶃweb.xmlಡΈࠐΈ ᶃ’ Ϋϥε໊औಘ αʔϒϨοτ Πϯελϯε ᶄੜ੒ ᶅdoGet/doPost ※࣮ࡍʹ͸ɺΫϥΠΞϯτ͔ΒͦͷαʔϒϨοτ΁ͷॳճϦΫΤετ͕͋ͬͨ࣌ʹɺαʔϒϨοτΠϯελϯε͕ੜ੒͞Ε·͢
  73. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ϦϑϨΫγϣϯͱ͸ʁ ▸ Ϋϥε໊΍ϝιου໊͔ΒɺΠϯελϯεੜ੒

    ΍ϝιου࣮ߦΛߦ͏࢓૊Έ 73 ”com.example.HelloServlet” HelloServletͷ Πϯελϯε
  74. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ϦϑϨΫγϣϯͷαϯϓϧίʔυ 74 //

    HelloServletΫϥεΛද͢ClassΠϯελϯεͷऔಘ Class klass = Class.forName("com.example.HelloServlet"); // HelloServletΫϥεͷҾ਺ͳ͠ίϯετϥΫλͷऔಘ Constructor constructor = klass.getConstructor(); // औಘͨ͠ίϯετϥΫλΛར༻ͯ͠ΠϯελϯεΛੜ੒ Object servlet = constructor.newInstance();
  75. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ϦϑϨΫγϣϯͷαϯϓϧίʔυ 75 //

    HelloServletΫϥεͷdoGet()ϝιουΛऔಘ Method method = klass.getMethod("doGet", String.class); // doGet()ϝιουͷ࣮ߦ Object returnValue = method.invoke(servlet, "hoge"); // doGet()ϝιουͷ໭Γ஋Λදࣔ System.out.println(returnValue);
  76. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ϦϑϨΫγϣϯ͕࢖ΘΕ͍ͯΔॴ ▸ 8FCϑϨʔϜϫʔΫɺ%*ίϯςφɺ03Ϛούʔ

    ͸ɺϦϑϨΫγϣϯΛϑϧ׆༻͍ͯ͠Δ ▸ Πϯελϯεͷੜ੒ ▸ ϝιουͷ࣮ߦ
 ɾɾɾͳͲ 76
  77. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 Ξϊςʔγϣϯͷऔಘ ▸ 8FCϑϨʔϜϫʔΫɺ%*ίϯςφɺ03Ϛούʔ

    Ͱ͸Ξϊςʔγϣϯ͕ଟ༻͞ΕΔ ▸ ϦϑϨΫγϣϯͱซͤͯ࢖ΘΕΔ͜ͱ͕ଟ͍ 77
  78. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 +1"ΤϯςΟςΟͷྫ 78 @Entity

    // ΤϯςΟςΟΫϥεͰ͋Δ͜ͱΛࣔ͢ @Table(name = "employee") // ରԠ͢Δςʔϒϧ໊ public class EmployeeEntity { @Id // ओΩʔͰ͋Δ͜ͱΛࣔ͢ private Integer id; @Column(name = "emp_name") // ྻ໊͕"emp_name" private String name; // getter/setter͸লུ
  79. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 Ϋϥεʹ෇͍͍ͯΔΞϊςʔγϣϯͷऔಘ 79 Class<Employee>

    klass = (Class<Employee>) Class.forName("com.example.Employee"); // EntityΞϊςʔγϣϯͷऔಘ Entity entity = klass.getAnnotation(Entity.class); if (entity != null) { System.out.println("͜ͷΫϥε͸ΤϯςΟςΟͰ͢"); } // TableΞϊςʔγϣϯͷऔಘ Table table = klass.getAnnotation(Table.class); System.out.println("ςʔϒϧ໊͸" + table.name());
  80. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ϑΟʔϧυʹ෇͍͍ͯΔΞϊςʔγϣϯͷऔಘ 80 Field[]

    fields = klass.getDeclaredFields(); for (Field field : fields) { String fieldName = field.getName(); Column column = field.getAnnotation(Column.class); String columnName = column.name(); System.out.println(fieldName + "ͷྻ໊͸" + columnName); Id id = field.getAnnotation(Id.class); if (id != null) { System.out.println(fieldName + "͸ओΩʔͰ͢"); } }
  81. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ͦͷଞͷ৔ॴͷΞϊςʔγϣϯͷऔಘ ▸ ϝιουɺϝιουҾ਺ͳͲʹ෇͍͍ͯΔΞ

    ϊςʔ γϣϯ΋औಘͰ͖Δ 81
  82. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ຊষͷ·ͱΊ ▸ Ϋϥε໊΍ϝιου໊ͷจࣈྻ͔ΒɺΠϯελϯ

    εੜ੒΍ϝιου࣮ߦ͕Ͱ͖Δʂ ▸ ΫϥεɾϝιουɾϑΟʔϧυͳͲʹ෇͍͍ͯΔ ΞϊςʔγϣϯΛऔಘͰ͖Δʂ ▸ 8FCϑϨʔϜϫʔΫɾ%*ίϯςφɾ03Ϛούʔ ͸ɺϦϑϨΫγϣϯ΍ΞϊςʔγϣϯͰ࡞ΒΕͯ ͍Δʂ 82
  83. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ᶃ ৽ਓݚमͰڭ͑Δ+BWBɺڭ͑ͳ͍+BWB ᶄ

    ϥΠϒϥϦΛ؆୯ʹ࢖͓͏ʂϏϧυπʔϧ.BWFO ᶅ 8FCࡾछͷਆثʂ8FCϑϨʔϜϫʔΫɾ
 %*ίϯςφɾ03Ϛούʔ ᶆ ϑϨʔϜϫʔΫͷ࢓૊ΈΛ஌Ζ͏ʂ
 ϦϑϨΫγϣϯͱΞϊςʔγϣϯ ᶇ τϥϒϧγϡʔςΟϯάʹඞਢʂ
 ϩΪϯάϥΠϒϥϦ-PHCBDL ᶈ ͜Ε͔ΒͲ͏ֶश͢Δ͔ʁ 83
  84. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ϩάͱ͸ʁ ▸ γεςϜͷʮه࿥ʯΛग़ྗͨ͠΋ͷ

    ▸ ͍ͭɺͲΜͳॲཧΛͨ͠ͷ͔ʁ ▸ τϥϒϧ࣌ʹ͸ϩά͕།ҰͷཔΓʹͳΔ 84
  85. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ͳͥϩΪϯάϥΠϒϥϦΛ࢖͏ͷʁ 4ZTUFNPVUQSJOUMO ͡Όμϝʁ

    ᶃϩάͷϨϕϧΛઃఆͰ͖Δ ▸ ։ൃ؀ڥͰ͸શϩάΛग़ྗɺຊ൪؀ڥͰ͸*/'0ϨϕϧҎ ্ͷΈग़ྗɺͱ͔ ᶄ౷Ұͨ͠ϑΥʔϚοτΛࢦఆͰ͖Δ ▸ ʮ<೥݄೔࣌෼ඵϛϦඵ><Ϋϥε໊>ϝοηʔδʯͱ͔ ᶅϑΝΠϧ΁ͷग़ྗ΍ɺผαʔόʔ΁ͷసૹͳͲ͕Ͱ ͖Δ 85
  86. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 -PHCBDLͱ͸ ▸ ΦʔϓϯιʔεͷϩΪϯάϥΠϒϥϦ

    ▸ ݱࡏͰ͸൪ϝδϟʔ 86
  87. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 -PHCBDLͷϩάϨϕϧ ▸ ઃఆϑΝΠϧʹࢦఆͨ͠ϨϕϧҎ্ͷΈग़ྗ͞ΕΔ

    87 ߴ ௿ ✦FSSPSʜΤϥʔ ✦XBSOʜܯࠂ ✦JOGPʜ௨ৗ ✦EFCVHʜσόοά ✦USBDFʜৄࡉͳτϨʔε
  88. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 MPHCBDLYNM ▸ ϩάϨϕϧ΍ϑΥʔϚοτΛࢦఆ͢Δ

    88 <configuration> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>logback-sample/testFile.log</file> <append>true</append> <encoder> <pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger{36} - %msg%n </pattern> </encoder> </appender> <root level="info"> <appender-ref ref="FILE" /> </root> </configuration>
  89. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ϩΨʔͷऔಘͱϩάͷग़ྗ 89 import

    org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SampleService { private static final Logger LOGGER = LoggerFactory.getLogger(SampleService.class); public void doSomething() { LOGGER.trace("This is trace log."); LOGGER.debug("This is debug log."); LOGGER.info("This is info log."); LOGGER.warn("This is warn log."); LOGGER.error("This is debug log."); } } logback.xmlʹࢦఆͨ͠ ϨϕϧҎ্ͷΈ ग़ྗ͞ΕΔ Ϋϥεͷ׬શम০໊͕ ϩΨʔͷ໊લͱͳΔ
  90. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ग़ྗ͞ΕͨϩάϑΝΠϧ 90 2016-12-02

    15:03:17.868 INFO com.example.service.SampleService - This is info log. 2016-12-02 15:03:17.868 WARN com.example.service.SampleService - This is warn log. 2016-12-02 15:03:17.868 ERROR com.example.service.SampleService - This is debug log. ▸ MPHCBDLYNMʹࢦఆͨ͠ ▸ ϨϕϧҎ্ͷΈग़ྗ͞ΕΔ ▸ ϝοηʔδͷϑΥʔϚοτͰग़ྗ͞ΕΔ
  91. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ͦͷଞͷͰ͖Δ͜ͱ ▸ ೔͝ͱʹϩάϑΝΠϧΛ෼͚Δ

    ▸ ʮϩʔϦϯάʯͱݺ͹ΕΔػೳ ▸ Ϋϥε΍ύοέʔδʹΑͬͯϨϕϧ΍ग़ྗઌΛ ෼͚Δ ▸ ϩΨʔͷ໊લʹΑΔ਌ࢠؔ܎Ͱࢦఆ 91
  92. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ΋ͬͱৄ͍͜͠ͱ͸ ▸ ٶ઒͞Μͷࢿྉ΁ʂ

    ▸ IUUQXXXTMJEFTIBSFOFUNJZBLBXBUBLVDPODFQUTBOEUPPMTPG MPHHJOHJOKBWB 92
  93. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ᶃ ৽ਓݚमͰڭ͑Δ+BWBɺڭ͑ͳ͍+BWB ᶄ

    ϥΠϒϥϦΛ؆୯ʹ࢖͓͏ʂϏϧυπʔϧ.BWFO ᶅ 8FCࡾछͷਆثʂ8FCϑϨʔϜϫʔΫɾ
 %*ίϯςφɾ03Ϛούʔ ᶆ ϑϨʔϜϫʔΫͷ࢓૊ΈΛ஌Ζ͏ʂ
 ϦϑϨΫγϣϯͱΞϊςʔγϣϯ ᶇ τϥϒϧγϡʔςΟϯάʹඞਢʂ
 ϩΪϯάϥΠϒϥϦ-PHCBDL ᶈ ͜Ε͔ΒͲ͏ֶश͢Δ͔ʁ 93
  94. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ࢢൢॻ੶Λ͔ͬ͠Γษڧ͢Δ ▸ +BWBͷจ๏

    94 ▸ 8FCͷجૅ ▸ +BWB4&
 ͷ৽ػೳ
  95. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ࢿ֨Λ໨ඪʹ͢Δ ▸ 0$+1(PMEɺ0$+8$

    ▸ ೥໨ͷऴΘΓ·Ͱʹ͸औΓ͍ͨ 95
  96. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ֤छϑϨʔϜϫʔΫ 96 ▸

    4QSJOH'SBNFXPSL·ͨ͸+BWB&&
  97. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ϑϨʔϜϫʔΫͷ࢓૊Έ ▸ ϦϑϨΫγϣϯ΍Ξ

    ϊςʔγϣ ϯɺϑϨʔϜϫʔΫͷ࢓૊Έ ʹ͍ͭͯৄ͘͠ࡌ͍ͬͯΔ 97
  98. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ϒϩάɺεϥΠυɺษڧձ ▸ ++6(φΠτηϛφʔʹߦ͖·͠ΐ͏ʂ

    ▸ ൃද͍ͯ͠Δਓୡͷϒϩά΍εϥΠυΛνΣο Ϋʂ 98
  99. (C) CASAREAL, Inc. All rights reserved. #ccc_f1 ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ 99 Enjoy

    Java!!