MapleStory Finger Point

๐ŸŸค JAVA/๐ŸŸค Spring 41

[Spring] Persistence Layer ๊ตฌํ˜„ (Data Access)

์˜์† ๊ณ„์ธต(Persistence Layer)์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์•„ํ‚คํ…์ฒ˜์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์˜๊ตฌ์ ์œผ๋กœ ์ €์žฅํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ๊ณ„์ธต์„ ์˜๋ฏธ   โ—ˆ  vo ํด๋ž˜์Šค ์ž‘์„ฑํ…Œ์ด๋ธ”์„ ๊ธฐ์ค€์œผ๋กœ vo ํด๋ž˜์Šค๋ฅผ ์ž‘์„ฑํ•ด์ค€๋‹ค.  โ—ˆ  mapper ์ž‘์—… (interface , xml or @ ์ž‘์„ฑ)1) root-context.xml ์—์„œ ํŒจํ‚ค์ง€ ์Šค์บ”์„ ์„ค์ •ํ•ด์ค˜์•ผํ•œ๋‹ค. 2) xml ๋กœ ๊ตฌํ˜„ํ• ๊ฑด์ง€ @ ๋กœ ๊ตฌํ˜„ํ• ๊ฑด์ง€ ์„ ํƒํ•œ๋‹ค๊ฐ„๋‹จํ•œ sql ์€ @ ์ถ”์ฒœ   โ—ˆ  test ํด๋ž˜์Šค๋กœ DB ์ž‘๋™ ํ…Œ์ŠคํŠธ1) @Autowired ๋ฅผ ํ†ตํ•ด์„œ Mapper ์ธํ„ฐํŽ˜์ด์…˜์˜ ๊ตฌํ˜„์ฒด๋ฅผ ์ฃผ์ž…์‹œํ‚จ๋‹ค.2) SQL develop ๋ฌธ์ œ๊ฐ€ ์—†๋Š”์ง€ or ๊ฒฐ๊ณผ ๊ฐ’ ์ฒดํ‚น  โ—ˆ xml or @ ์–ด๋…ธํ…Œ์ด์…˜ ์ž‘์„ฑ1) xml SELECT * FROM users WHERE..

[Spring] Spring JDBC ์™€ Mybatis

โ—ˆ JDBC connection ์ง์ ‘ ์ฒ˜๋ฆฌpropareStatement ์ƒ์„ฑ ์ฒ˜๋ฆฌsql ์ž‘์„ฑresultSet (select ๋ฌธ) ์ฒ˜๋ฆฌclose() ๋ฆฌ์†Œ์Šคํ•ด์ œ โ—ˆ Spring JDBC Connection Pool DataSource  (์ธํ„ฐํŽ˜์ด์Šค์ž„)  ๋กœ ์ปค๋„ฅ์…˜ ํ’€์„ ์‚ฌ์šฉํ•œ๋‹ค.   ์ปค๋„ฅ์…˜ ํ’€์€ ์—ฌ๋Ÿฌ ์ข…๋ฅ˜๊ฐ€ ์žˆ๋‹ค.์ตœ๊ทผ ์œ ํ–‰ํ•˜๋Š” ๊ฑด   (Hikari cp ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ) (Spring jdbc + Connection ) ๐Ÿ”Œpom.xml ์— ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ถ”๊ฐ€  --- Hikari cp       โ—ˆ Mybatis  sql ๋งคํ•‘ ํ”„๋ ˆ์ž„์›Œํฌ mybatis-spirng ์ด๋ผ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ํ†ตํ•ด ์‰ฝ๊ฒŒ ์—ฐ๋™ ์ž‘์—… ๊ฐ€๋Šฅ   ๐ŸคคํŠน์ง• 1(DAO ๋Œ€์‹ ์— Mapper ์‚ฌ์šฉ)(java ์ฝ”๋“œ ๋Œ€์‹  xml ์‚ฌ์šฉ) ๐Ÿคค ํŠน์ง•2 :: ์ž๋™..

[Spring] MVC Controller, Service, DAO

๐Ÿ’ป Controller ํ™”๋ฉด ์ฒ˜๋ฆฌ@Controller@Requestmapping1) void2) String 3) redirect4) ResponseBody  ๐Ÿ’ป Request ํŒŒ๋ผ๋ฏธํ„ฐ1) ์ „ํ†ต์  HttpServletRequest ๊ฐ์ฒด๋กœ  HTTP ์ •๋ณด ์–ป๊ธฐString name = request.getParameter("name") 2) ์–ด๋…ธํ…Œ์ด์…˜์œผ๋กœ  HTTP ์ „์†ก ์ •๋ณด ์–ป๊ธฐ (๋‹จ์ผ๊ฐ’)@RequestParam(value=๏ผ‚ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ’", required = false, defaultValue = “๊ธฐ๋ณธ๊ฐ’") 3) ์ปค๋ฉ˜๋“œ ๊ฐ์ฒด  HTTP ์ „์†ก ์ •๋ณด ์–ป๊ธฐvo๊ฐ์ฒด์— ๋™์ผํ•œ setter ๊ฐ€ ์žˆ์œผ๋ฉด ์ž๋™ ์ €์žฅ ๐Ÿ’ป Model ํ™”๋ฉด์— ๋ฐ์ดํ„ฐ ์ „๋‹ฌํ•ด์ฃผ๋Š” ๊ฐ์ฒด  1) Model2) ModelAndView3) Mod..

[Spring] ์Šคํ”„๋ง MVC ํ”„๋ ˆ์ž„์›Œํฌ ๊ตฌ์กฐ

๐Ÿ’ป ์Šคํ”„๋ง MVC ํ”„๋ ˆ์ž„์›Œํฌ ๋™์ž‘๊ตฌ์กฐ 1) ์‚ฌ์šฉ์ž๊ฐ€ ์š”์ฒญ์„ ๋ณด๋‚ธ๋‹ค.2) DispatcherServlet ์ด ์š”์ฒญ์„ ๋ฐ›๋Š”๋‹ค.3) HandlerMapping ๊ฐ์ฒด์— Controller ๊ฐ์ฒด ๊ฒ€์ƒ‰์„ ์š”์ฒญํ•œ๋‹ค.=> ๋ชจ๋“  Controller ๊ฐ์ฒด๋ฅผ ๊ฒ€์ƒ‰ ํ›„ DispatcherServlet ๊ฐ์ฒด์— ๋ฐ˜ํ™˜ํ•œ๋‹ค.4) DispatcherServlet  ๋Š” ๋‹ค์‹œ HandlerAdapter ๊ฐ์ฒด์— ์‚ฌ์šฉ์ž์˜ ์š”์ฒญ์— ๋ถ€ํ•ฉํ•˜๋Š” ๋ฉ”์†Œ๋“œ ๊ฒ€์ƒ‰์„ ์š”์ฒญํ•œ๋‹ค.=> HandlerAdpter ๊ฐ์ฒด๋Š” ์š”์ฒญ์— ๋ถ€ํ•ฉํ•˜๋Š” ๋ฉ”์†Œ๋“œ๋ฅผ ์ฐพ์•„์„œ ํ•ด๋‹น Controller ๊ฐ์ฒด์˜ ๋ฉ”์†Œ๋“œ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค.5) Controller ๊ฐ์ฒด์˜ ๋ฉ”์†Œ๋“œ๊ฐ€ ์‹คํ–‰๋˜๋ฉด, HandlerAdapter ๊ฐ์ฒด์— ModelAndView  ๊ฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.6) ModelAndView ๊ฐ์ฒด์—๋Š”..

[Spring Boot] IntelliJ IDEA (์ธํ…”๋ฆฌ์ œ์ด) ์„ธํŒ… ๋ฐฉ๋ฒ• + ์„œ๋ฒ„์ž‘๋™๊นŒ์ง€

โˆ˜โ‚Šโœงโ”€ (1) Inteli J ์„ค์น˜ โ”€โœงโ‚Šโˆ˜ https://www.jetbrains.com/ko-kr/์ธํ…”๋ฆฌ์ œ์ด ์‚ฌ์ดํŠธ ๋“ค์–ด๊ฐ€๊ธฐ inteliJ Comunity ๋ฒ„์ „์€ ์˜คํžˆ๋ ค STS๋ณด๋‹ค ์ง€์› ์•ˆ๋˜๋Š” ๊ธฐ๋Šฅ์ด ๋งŽ์Šต๋‹ˆ๋‹ค.ํ•™์ƒ ์ด๋ฉ”์ผ์ด ์žˆ๋Š” ๊ฒฝ์šฐ ultimate๋ฒ„์ „์„ ๋ฌด๋ฃŒ๋กœ ์“ธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.  zip ๋ฒ„์ „ ๋‹ค์šด๋กœ๋“œ   bin ํด๋” ์•ˆ์— idea64.exe ์‹คํ–‰ํ•˜๋ฉด ๋จ  โˆ˜โ‚Šโœงโ”€ (2) Spring Initializr ( ๊ตฌ์กฐ ์žก๊ธฐ )โ”€โœงโ‚Šโˆ˜   https://start.spring.io/์ธํ…”๋ฆฌ์ œ์ด comunity๋ฒ„์ „์€ ์Šคํ”„๋ง๋ถ€ํŠธ ๋ผˆ๋Œ€ ๊ตฌ์กฐ๋ฅผ ์žก๋Š” ๋ฐฉ๋ฒ•์ด ์—†๋‹ค. ๐Ÿ˜ญSpring Initializr ์— ๋“ค์–ด๊ฐ€์„œ ๊ธฐ๋ณธ ๋ผˆ๋Œ€๊ตฌ์กฐ๋ฅผ ์žก์•„์ฃผ๊ณ  ์‹œ์ž‘ํ•œ๋‹ค!     ํ”„๋กœ์ ํŠธ metadata ๋Š” ๊ฐ์ž ๋„ค์ด๋ฐํ•ด์ฃผ๊ณ  / Depend..

[Spring] Container ๊ณผ Bean

๐Ÿ’ป Spring  Container (์ปจํ…Œ์ด๋„ˆ) ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๊ฐ์ฒด ์ƒ๋ช… ์ฃผ๊ธฐ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์ค‘์‹ฌ์ ์ธ ์ปดํฌ๋„ŒํŠธ์ž…๋‹ˆ๋‹ค.์ปจํ…Œ์ด๋„ˆ๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๊ฐ์ฒด๋“ค์„ ์ƒ์„ฑํ•˜๊ณ ,๊ทธ๋“ค ๊ฐ„์˜ ์˜์กด์„ฑ์„ ์„ค์ •ํ•˜๋ฉฐ,๊ฐ์ฒด์˜ ์ดˆ๊ธฐํ™”์™€ ์ข…๋ฃŒ ๊ณผ์ •์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.  ์˜์กด์„ฑ ์ฃผ์ž… (Dependency Injection): ์ปจํ…Œ์ด๋„ˆ๋Š” ๊ฐ์ฒด์˜ ์˜์กด์„ฑ์„ ์ž๋™์œผ๋กœ ์ฃผ์ž…ํ•ด์ค๋‹ˆ๋‹ค. ์ด๋Š” ๊ฐ์ฒด๊ฐ€ ์ž์‹ ์ด ํ•„์š”ํ•œ ๋‹ค๋ฅธ ๊ฐ์ฒด๋ฅผ ์ง์ ‘ ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜ ๊ด€๋ฆฌํ•˜์ง€ ์•Š๋„๋ก ํ•˜์—ฌ ์ฝ”๋“œ์˜ ๊ฒฐํ•ฉ๋„๋ฅผ ๋‚ฎ์ถ”๊ณ , ํ…Œ์ŠคํŠธ ๊ฐ€๋Šฅ์„ฑ๊ณผ ์œ ์—ฐ์„ฑ์„ ๋†’์ž…๋‹ˆ๋‹ค. ๋ผ์ดํ”„์‚ฌ์ดํด ๊ด€๋ฆฌ: ์ปจํ…Œ์ด๋„ˆ๋Š” Bean์˜ ์ƒ์„ฑ, ์ดˆ๊ธฐํ™”, ์†Œ๋ฉธ๊นŒ์ง€์˜ ์ „ ๊ณผ์ •์„ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด ๊ฐ์ฒด ๊ด€๋ฆฌ์— ๋Œ€ํ•œ ๋ถ€๋‹ด์„ ์ค„์ด๊ณ , ์ผ๊ด€๋œ ๋ฐฉ์‹์œผ๋กœ ๊ฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.  ๐Ÿ’ป Spring  Bean (๋นˆ) Spring Conta..

[Spring] Maven (pom.xml) - ์Šคํ”„๋ง ์กฐ๋ฆฝ

jsp ์— ๋นŒ๋“œํˆด์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€1. Maven 2. Gradle ์ด ์žˆ๋‹ค.   ์Šคํ”„๋ง์€ ํ”„๋กœ์ ํŠธ๋ฅผ ์–ด๋–ป๊ฒŒ ์ƒ์„ฑํ•˜๋Š๋ƒ์— ๋”ฐ๋ผ์„œ => ํ”„๋กœ์ ํŠธ ๊ตฌ์กฐ๊ฐ€ ๋‹ฌ๋ผ์ง„๋‹ค.ํ”„๋กœ์ ํŠธ ์ดˆ๊ธฐ ๊ตฌ์ถ• ํ™˜๊ฒฝ์— ๋”ฐ๋ผ ๋งŽ์ด ๋‹ฌ๋ผ์งˆ ์ˆ˜ ์žˆ๋‹ค.  ๐Ÿ’ป Maven ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ• 1) Dynamic Web Project ์ƒ์„ฑํ•˜๊ธฐ2) ๊ธฐ๋ณธ ํŒŒ์ผ ํด๋”๋ช…์„ src/main/java ๋กœ ๋ณ€๊ฒฝ3) Content director ์„ webapp ๋กœ ๋ณ€๊ฒฝ (web.xml ์ƒ์„ฑ ๋ฒ„ํŠผ ํด๋ฆญ)4) ์›น ํ”„๋กœ์ ํŠธ๋ฅผ ์šฐํด๋ฆญํ•ด์„œ Covert to Maven Project ๋ฅผ ํด๋ฆญ5)6) ์™„์„ฑ๋œ pom.xml       ๐Ÿ’ป  Maven ์ด๋ž€ ? ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ(๋ชจ๋“ˆ) ์„ ์—ฐ๊ฒฐํ•ด์ฃผ๊ณ  ๋นŒ๋“œ๋ฅผ ์œ„ํ•œ ํ”Œ๋žซํผ์ด๋‹ค.์ฆ‰ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์ •์œผ๋กœ ๋ฐ”๋กœ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•˜๋‹ค.    ๐Ÿ’ป M..

[Spring] IoC (์ œ์–ด์˜์—ญ์ „), DI (์˜์กด์„ฑ์ฃผ์ž…)

๐Ÿ’ป  IoC (Inversion of Control) ์ œ์–ด์˜ ์—ญ์ „๊ฐ์ฒด์˜ ์ƒ์„ฑ๊ณผ ์˜์กด์„ฑ ๊ด€๋ฆฌ์˜ ์ œ์–ด๋ฅผ ํ”„๋ ˆ์ž„์›Œํฌ / ์ปจํ…Œ์ด๋„ˆ์— ๋งก๊น€ (๊ฐœ๋ฐœ์ž๋Š” ๊ด€์—ฌํ•˜์ง€ ์•Š๋Š”๋‹ค)๊ฐ์ฒด๋ฅผ ํ•„์š”ํ•  ๋•Œ ์ƒ์„ฑํ•ด์„œ ์‚ฌ์šฉํ•˜๋˜ ๋ฐฉ์‹์„ ๋ฏธ๋ฆฌ ์ƒ์„ฑํ•ด ๋†“๊ณ  ๊บผ๋‚ด์„œ ์‚ฌ์šฉํ•˜๋Š” ํ˜•ํƒœ๋กœ ๋ณ€๊ฒฝ     ๐Ÿ’ป DI (Dependency Injection) ์˜์กด์„ฑ ์ฃผ์ž…DI : Dependency Injection IoC ๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๋ฐฉ์‹ ์ค‘ ํ•˜๋‚˜์ž์‹ ์˜ ์˜์กด์„ฑ์„ ์™ธ๋ถ€์—์„œ ์ฃผ์ž… ๋ฐ›๋Š” ๋ฐฉ์‹์ด๋‹ค.์Šคํ”„๋ง Container ์— ๋งŒ๋“ค์–ด๋‘” ๊ฐ์ข… ํด๋ž˜์Šค(bean)๋“ค์€ ์„œ๋กœ ์˜์กด์ ์ด๋‹ค.ํ”„๋กœ๊ทธ๋ž˜๋ฐ์—์„œ ๊ฐ์ฒด๋ฅผ ๋งŒ๋“ค์–ด์„œ ์™ธ๋ถ€์—์„œ ๋”ฐ๋กœ ์ฃผ์ž…ํ•˜๋Š” ๋ฐฉ๋ฒ•     ๐Ÿ’ป ์˜์กด์„ฑ ์ฃผ์ž… 2๊ฐ€์ง€ ๋ฐฉ๋ฒ•1) ์ƒ์„ฑ์ž๋ฅผ ํ†ตํ•œ ์˜์กด์„ฑ ์ฃผ์ž…2) setter๋ฅผ ํ†ตํ•œ ์˜์กด์„ฑ ์ฃผ์ž…  ์ƒ์„ฑ์ž ์ฃผ์ž… ๋ฐฉ์‹ pom...

[Spring] ์Šคํ”„๋ง ์ดˆ๊ธฐ ์„ธํŒ… ๋ฐฉ๋ฒ•

1) jdk ์„ค์น˜2) spring ์„ค์น˜ (eclipse)3) tomcat ์„ค์น˜ (์„œ๋ฒ„) โˆ˜โ‚Šโœงโ”€โ”€โ”€ (1) JDK ์„ค์น˜ โ”€โ”€โ”€โœงโ‚Šโˆ˜   โ— ์˜ค๋ผํด์‚ฌ์ดํŠธ์—์„œ jdk ๋‹ค์šด๋กœ๋“œhttps://www.oracle.com/java/technologies/downloads/ Download the Latest Java LTS FreeSubscribe to Java SE and get the most comprehensive Java support available, with 24/7 global access to the experts.www.oracle.comSE : Standard EditionEE : Enterprise Edition(๊ธฐ์—…์šฉ)  jdk 21 ๋ฒ„์ „์œผ๋กœ ๋‹ค์šด๋ฐ›์•„์คฌ๋‹ค.  exe ํŒŒ์ผ์„ ๋”๋ธ”ํด๋ฆญ jdk ..