๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐ŸŒฟ Spring33

[Spring Boot/RESTful] JPA ์‚ฌ์šฉ / H2 database(+sql ๋ฒ„์ „ ์˜ค๋ฅ˜) JPA Java Persistence API ์ž๋ฐ” ORM ๊ธฐ์ˆ ์— ๋Œ€ํ•œ API ํ‘œ์ค€ ๋ช…์„ธ(Object Relationship Mapping) ์ž๋ฐ” ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ๊ด€๊ณ„ํ˜• ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹์„ ์ •์˜ํ•œ ์ธํ„ฐํŽ˜์ด์Šค → ๋ฉ”์†Œ๋“œ ์„ ์–ธ๋ฌธ๋งŒ ์กด์žฌ. ์šฐ๋ฆฌ๋Š” ๊ตฌํ˜„์ฒด๋ฅผ ๊ฐ€์ง€๊ณ  ๊ฐœ๋ฐœ์„ ํ•ด์•ผ ํ•œ๋‹ค ⇒ Hibernate EntityManager๋ฅผ ํ†ตํ•ด CRUD ์ฒ˜๋ฆฌ Hibernate JPA์˜ ๊ตฌํ˜„์ฒด, ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ง์ ‘ ๊ตฌํ˜„ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ⇒ JPA์˜ EntityManager๋ฅผ ๊ตฌํ˜„ ๊ฐ์ฒด ๊ด€๊ณ„ ๋งคํ•‘ ํ”„๋ ˆ์ž„์›Œํฌ ์ƒ์‚ฐ์„ฑ, ์œ ์ง€๋ณด์ˆ˜, ๋น„์ข…์†์„ฑ Spring Data JPA Spring Module JPA๋ฅผ ์ถ”์ƒํ™”ํ•œ Repository ์ธํ„ฐํŽ˜์ด์Šค ์ œ๊ณต ์ธํ„ฐํŽ˜์ด์Šค ์„ ์–ธ ๋งŒ์œผ๋กœ๋„ Spring์—์„œ ์ œ๊ณตํ•˜๋Š” CRUD ๊ธฐ๋Šฅ ์‚ฌ์šฉ ๊ฐ€๋Šฅ 1. .. 2022. 2. 19.
[Spring Boot/RESTful] Spring Security๋ฅผ ์ด์šฉํ•œ ๋กœ๊ทธ์ธ [๊ธฐ๋ณธ] dependency ์ถ”๊ฐ€ org.springframework.boot spring-boot-starter-security 1. ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋˜๋Š” username, password๋ฅผ ์ด์šฉ 1) ๊ธฐ๋ณธ password ํ™•์ธ dependency๋ฅผ ์„ค์ •ํ•œ ํ›„, ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์‹คํ–‰ํ•˜์—ฌ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ํ™•์ธํ•ด์•ผ ํ•œ๋‹ค. (์›น์„œ๋ฒ„๋ฅผ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด ํ•„์š”) 2) ์›น ๋ธŒ๋ผ์šฐ์ € ์š”์ฒญ ์ธ์ฆ์ด ๋˜์–ด ์žˆ์ง€ ์•Š๋‹ค๋ฉด 401 Unauthorized๊ฐ€ ๋œฌ๋‹ค. ์—ฌ๊ธฐ์—์„œ username ๊ฐ’์„ user๋กœ ํ•ด๋„ ๋ถˆ๋Ÿฌ์™€์ง€๋Š” ์ด์œ ๋Š” spring security์˜ ๊ธฐ๋ณธ ์„ค์ • ๋•Œ๋ฌธ์ด๋‹ค. Spring Security ๊ธฐ๋ณธ ์„ค์ • spring.security.user.name / spring.security.user.password๋ฅผ ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ๊ธฐ๋ณธ.. 2022. 2. 18.
[Spring Boot/RESTful] HAL Browser(Explorer) (+๋ฒ„์ „ ์—๋Ÿฌ) HAL Browser Hypertext Application Language REST API ์„ค๊ณ„ ์‹œ Response message์˜ ํฌ๋งท๊ณผ๋Š” ์ƒ๊ด€์—†์ด API๋ฅผ ์‰ฝ๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ฉ”ํƒ€์ •๋ณด๋ฅผ ํ•˜์ดํผ๋งํฌ ํ˜•์‹์œผ๋กœ ์ œ๊ณตํ•œ๋‹ค. API ๋ฆฌ์†Œ์Šค ์‚ฌ์ด์—์„œ ์ผ๊ด€์ ์ธ ํ•˜์ดํผ๋งํฌ๋ฅผ ์ œ๊ณต API ์„ค๊ณ„์—์„œ HAL์„ ๋„์ž…ํ•˜๊ฒŒ ๋˜๋ฉด API ๊ฐ„ ์‰ฌ์šด ๊ฒ€์ƒ‰์ด ๊ฐ€๋Šฅํ•ด์ง„๋‹ค. → ๋” ๋‚˜์€ ๊ฐœ๋ฐœํ™˜๊ฒฝ ์ œ๊ณต dependency ์ถ”๊ฐ€ org.springframework.data spring-data-rest-hal-browser HAL Browser๊ฐ€ deprecated ๋˜์–ด์„œ ์ตœ์‹  spring boot ๋ฒ„์ „์—์„œ๋Š” HAL explorer๋ฅผ ํ†ตํ•ด ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค. (์•„๋ž˜์—์„œ ๋ฒ„์ „ ์ถ”๊ฐ€ ์•ˆ ํ•˜๋ฉด ์—๋Ÿฌ๋‚จ) org.springframework.dat.. 2022. 2. 18.
[Spring Boot/RESTful] REST API Monitoring์„ ์œ„ํ•œ Actuator(+spring fox PathPatternParser ์ด์Šˆ) Actuator ํ˜„์žฌ ๊ธฐ๋™ํ•˜๊ณ  ์žˆ๋Š” ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์ƒํƒœ๋ฅผ ์‰ฝ๊ฒŒ monitoringํ•  ์ˆ˜ ์žˆ๋‹ค. ํ˜„์žฌ ์„œ๋ฒ„๊ฐ€ ๊ตฌ๋™ ์ค‘์ธ์ง€๋„ ํ™•์ธ ๊ฐ€๋Šฅ ๊ธฐ๋ณธ ์ œ๊ณตํ•˜๋Š” ๋งํฌ๋ฅผ ๋ณ„๋„๋กœ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•ํ•ด์„œ ์‚ฌ์šฉํ•˜๋ฉด ๋” ์ข‹๋‹ค. Actuator ๊ตฌํ˜„ dependency ์ถ”๊ฐ€ org.springframework.boot spring-boot-starter-actuator ์—๋Ÿฌ Actuator๋Š” PathPatternParser๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ง€๋‚œ Swagger ์„ค์ •์—์„œ ํ—ˆ์šฉํ•ด์คฌ๋˜ yml ์„ค์ •์œผ๋กœ๋Š” ํ•ด๊ฒฐ๋˜์ง€ ์•Š๋Š”๋‹ค. org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; https://git.. 2022. 2. 18.