์ „์ฒด ๊ธ€

์ „์ฒด ๊ธ€

    [Redis] M1 MacOS์—์„œ Docker Redis Cluster ์„ค์ •ํ•˜๊ธฐ + SpringBoot ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ํด๋Ÿฌ์Šคํ„ฐ ์—ฐ๊ฒฐํ•˜๊ธฐ

    [Redis] M1 MacOS์—์„œ Docker Redis Cluster ์„ค์ •ํ•˜๊ธฐ + SpringBoot ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ํด๋Ÿฌ์Šคํ„ฐ ์—ฐ๊ฒฐํ•˜๊ธฐ

    ๐Ÿค” ๊ฐœ์š” [Redis] Redis์˜ ๋ฐฑ์—…๊ณผ HA๋ฅผ ์œ„ํ•œ ์ „๋žต (RDB, AOF, Replication, Sentinel, Sharding, Cluster)๐Ÿ0. ์„œ๋ก  ํŒ€ ํ”„๋กœ์ ํŠธ์—์„œ Redis๋ฅผ ์‚ฌ์šฉํ•˜๋‹ค๊ฐ€, ์‹ ๊ธฐํ•œ ํ˜„์ƒ์„ ๋ฐœ๊ฒฌํ–ˆ๋‹ค. ์šฐ๋ฆฌ ํ”„๋กœ์ ํŠธ์—์„œ๋Š” ๋„์ปค๋ฅผ ํ†ตํ•ด ๋ ˆ๋””์Šค ์„œ๋ฒ„๋ฅผ ๋Œ๋ฆฌ๊ณ  ์žˆ์—ˆ๊ณ , JWT Refresh Token์„ ๋ ˆ๋””์Šค ์„œ๋ฒ„์— ์ €์žฅํ•˜๊ณ  ์žˆ์—ˆ๋Š”๋ฐ ๋„hoons-dev.tistory.com ์ด์ „ ๊ธ€์„ ๋ณด๋ฉด, ๋ ˆ๋””์Šค์˜ ๋ฐฑ์—…๊ณผ ๊ณ ๊ฐ€์šฉ์„ฑ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ์ด์•ผ๊ธฐ๊ฐ€ ๋‹ด๊ฒจ์žˆ์Šต๋‹ˆ๋‹ค.Redis์˜ ๊ณ ๊ฐ€์šฉ์„ฑ์„ ์œ„ํ•ด์„œ Cluster๋ฅผ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ ์ค‘์—์„œ๋„ Docker Desktop for Mac์„ ์‚ฌ์šฉํ•˜๋ฉด์„œ Redis-Cluster๋ฅผ ๊ตฌ์ถ•ํ•  ์ˆ˜ ์žˆ๋„๋ก Docker-Compose ํŒŒ์ผ ๊ตฌ์„ฑ๊ณผ Sprin..

    [QueryDSL] QueryDSL-JPA : DTO Projection๊ณผ Transform

    [QueryDSL] QueryDSL-JPA : DTO Projection๊ณผ Transform

    QueryDSL์„ ์‚ฌ์šฉํ•˜๋ฉด์„œ ์กฐํšŒ Query ์„ฑ๋Šฅ์„ ๋†’์ด๋Š” ๋ฐฉ๋ฒ• ์ค‘์— ํ•˜๋‚˜๋Š”, ์—”ํ‹ฐํ‹ฐ๊ฐ€ ์•„๋‹Œ DTO๋กœ ๊ฐ’์„ ๋ฐ›์œผ๋ฉด ์†๋„ ํ–ฅ์ƒ์„ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.๊ทธ ์ด์œ ๋Š” ์•„๋ž˜์™€ ๊ฐ™์€๋ฐ์š”. 1. ํ•„์š”ํ•œ ํ•„๋“œ๋งŒ ์กฐํšŒํ•˜๋ฏ€๋กœ ๋‹น์—ฐํ•˜๊ฒŒ๋„ ์กฐํšŒ ์†๋„๊ฐ€ ์ฆ๊ฐ€ํ•œ๋‹ค.SQL์˜ SELECT๋ฌธ์„ ๋ณด๋ฉด, ํ•„์š”ํ•œ ์ปฌ๋Ÿผ๋งŒ ์–ป์–ด์˜ค๋Š” ๊ฒƒ์ด ํ…Œ์ด๋ธ” ์ „์ฒด๋ฅผ ์–ป์–ด์˜ค๋Š” ๊ฒƒ๋ณด๋‹ค ๋‹น์—ฐํ•˜๊ฒŒ๋„ ๋น ๋ฆ…๋‹ˆ๋‹ค. DTO๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๋งŒ ์กฐํšŒํ•˜๋ ค๋Š” ์˜๋„๊ฐ€ ๋‚ดํฌ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋ถˆํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ค์ง€ ์•Š์Œ์œผ๋กœ์จ ์ฟผ๋ฆฌ ์„ฑ๋Šฅ์„ ์ตœ์ ํ™” ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 2. JPA์˜ ์˜์†์„ฑ ์ปจํ…์ŠคํŠธ์˜ ๊ด€๋ฆฌ๋Œ€์ƒ์ด ์•„๋‹ˆ๋‹ค.์—”ํ‹ฐํ‹ฐ๋Š” JPA์˜ ๊ด€๋ฆฌ ๋Œ€์ƒ์ด๋ฏ€๋กœ ์˜์†์„ฑ ์ปจํ…์ŠคํŠธ์— ์˜ํ•ด ๊ด€๋ฆฌ๋ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์—”ํ‹ฐํ‹ฐ๋ฅผ ์กฐํšŒํ•  ๋•Œ๋Š” ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰์ด ์ƒ๋Œ€์ ์œผ๋กœ ๋” ๋งŽ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.๋ฐ˜๋ฉด DTO๋Š” ์ˆœ์ˆ˜ํ•œ..

    [QueryDSL] QueryDSL-JPA : JOIN ํ•˜๊ธฐ

    [QueryDSL] QueryDSL-JPA : JOIN ํ•˜๊ธฐ

    ๐Ÿ ํ™˜๊ฒฝ- QueryDSL 5.0.0- Spring Data JPA 3.1.2  ๐Ÿ’œ JOIN ์ข…๋ฅ˜1. INNER JOINJOIN ๋‹นํ•˜๋Š” ํ…Œ์ด๋ธ”์„ A, JOIN์„ ๊ฑฐ๋Š” ํ…Œ์ด๋ธ”์„ B๋ผ๊ณ  ํ•  ๋•Œ, A์™€ B ํ…Œ์ด๋ธ” ๋ชจ๋‘ JOIN์„ ํ•˜๋ ค๋Š” ๋Œ€์ƒ Key ์ปฌ๋Ÿผ์— ๋Œ€ํ•ด ๊ฐ’์ด ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ๋งŒ JOIN์„ ํ•˜๋Š” ๊ฒƒ์„ INNER JOIN์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. queryDSL์—์„œ Inner join์„ ์“ฐ๋Š” ๋ฐฉ๋ฒ•์€ ๊ฐ„๋‹จํ•ฉ๋‹ˆ๋‹ค.queryFactory์—์„œ select์™€ from์ ˆ ์ดํ›„์— join ๋ฉ”์„œ๋“œ๋ฅผ ํฌํ•จํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์•„๋ž˜๋Š” ์ฝ”๋“œ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค. @Entity@Getter@Table(name = "neo_starpage")public class StarPage { @EmbeddedId @AttributeOverride(na..

    [QueryDSL] QueryDSL-JPA : @ElementCollection VO์— ๋Œ€ํ•œ JOIN

    [QueryDSL] QueryDSL-JPA : @ElementCollection VO์— ๋Œ€ํ•œ JOIN

    ๐Ÿ ํ™˜๊ฒฝ - QueryDSL 5.0.0 - Spring Data JPA 3.1.2 ๐Ÿค” ์‚ฌ์šฉ๋œ ๋„๋ฉ”์ธ ์ฝ”๋“œ ๐Ÿ’œ StarPage Aggregate Root @Entity @Getter @Table(name = "neo_starpage") public class StarPage { @EmbeddedId @AttributeOverride(name = "value", column = @Column(name = "star_page_id")) private StarPageId starPageId; @Embedded private StarPageInfo information; @ElementCollection @CollectionTable(name = "neo_starpage_admin", joinColumns = @..

    [Redis] Redis์˜ ๋ฐฑ์—…๊ณผ HA๋ฅผ ์œ„ํ•œ ์ „๋žต (RDB, AOF, Replication, Sentinel, Sharding, Cluster)

    [Redis] Redis์˜ ๋ฐฑ์—…๊ณผ HA๋ฅผ ์œ„ํ•œ ์ „๋žต (RDB, AOF, Replication, Sentinel, Sharding, Cluster)

    ๐Ÿ0. ์„œ๋ก  ํŒ€ ํ”„๋กœ์ ํŠธ์—์„œ Redis๋ฅผ ์‚ฌ์šฉํ•˜๋‹ค๊ฐ€, ์‹ ๊ธฐํ•œ ํ˜„์ƒ์„ ๋ฐœ๊ฒฌํ–ˆ๋‹ค. ์šฐ๋ฆฌ ํ”„๋กœ์ ํŠธ์—์„œ๋Š” ๋„์ปค๋ฅผ ํ†ตํ•ด ๋ ˆ๋””์Šค ์„œ๋ฒ„๋ฅผ ๋Œ๋ฆฌ๊ณ  ์žˆ์—ˆ๊ณ , JWT Refresh Token์„ ๋ ˆ๋””์Šค ์„œ๋ฒ„์— ์ €์žฅํ•˜๊ณ  ์žˆ์—ˆ๋Š”๋ฐ ๋„์ปค๋ฅผ ์ค‘์ง€ํ•˜๊ณ  ๋ฉฐ์น  ๋’ค์— ๋‹ค์‹œ ์‹คํ–‰์„ ํ•ด๋ณธ ๊ฒฐ๊ณผ ์•„์ง ํ•ด๋‹น ํ† ํฐ๋“ค์ด ๋‚จ์•„์žˆ๋Š” ํ˜„์ƒ์„ ๋ฐœ๊ฒฌํ–ˆ๋‹ค. "์—ฅ? Redis๋Š” InMemory DB๋กœ ์ข…๋ฃŒ๋˜๋ฉด ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ๋ชจ๋‘ ํœ˜๋ฐœ๋˜์–ด ๋ฐ์ดํ„ฐ๊ฐ€ ์—†๋Š”๊ฒŒ ๋งž์ง€ ์•Š๋‚˜?" ์ด๋Ÿฌํ•œ ์ƒ๊ฐ์„ ๊ฐ€์ง€๊ฒŒ ๋˜์—ˆ๊ณ , Redis์˜ ๋ฐฑ์—…์— ๊ด€๋ จ๋œ ๋‚ด์šฉ์„ ๊ณต๋ถ€ํ•˜์ž ํ•ด๋‹น ์‹ค๋งˆ๋ฆฌ๋ฅผ ํ’€์–ด๋‚ผ ์ˆ˜ ์žˆ์—ˆ๋‹ค. ๐Ÿค” 1. Redis์˜ ๋ฐฑ์—… ๋ฐฉ์‹ 1-1. RDB(Redis DataBase ๋ฐฉ์‹) ์—ฌ๊ธฐ์„œ RDB๋Š” ๊ด€๊ณ„ํ˜• ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๊ฐ€ ์•„๋‹ˆ๋ผ, Redis์˜ ์ž์ฒด์ ์ธ ๋ฐฑ์—… ๋ฐฉ์‹์ธ Redis Database ๋ฐฉ์‹์„..

    [Spring] Spring Security + OAuth2.0 + JWT Token์„ ํ™œ์šฉํ•œ ์†Œ์…œ๋กœ๊ทธ์ธ ์ด์ •๋ฆฌ - (1) ๋ฐฐ๊ฒฝ ์ง€์‹ ์ดํ•ดํ•˜๊ธฐ, ์ „์ฒด ๊ทธ๋ฆผ ์‚ดํŽด๋ณด๊ธฐ

    [Spring] Spring Security + OAuth2.0 + JWT Token์„ ํ™œ์šฉํ•œ ์†Œ์…œ๋กœ๊ทธ์ธ ์ด์ •๋ฆฌ - (1) ๋ฐฐ๊ฒฝ ์ง€์‹ ์ดํ•ดํ•˜๊ธฐ, ์ „์ฒด ๊ทธ๋ฆผ ์‚ดํŽด๋ณด๊ธฐ

    ๐Ÿ™‹๐Ÿป ์„œ๋ก  NEO ํ† ์ด ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ ์†Œ์…œ ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ธํ„ฐ๋„ท ์ƒ์˜ ๋งŽ์€ ๊ธ€์„ ์ฝ๊ณ , ๋„์›€์„ ๋งŽ์ด ๋ฐ›์•˜์œผ๋‚˜ ์ •๋ณด๊ฐ€ ํ•œ๋ฐ ๋ชจ์—ฌ์žˆ์ง€ ์•Š๊ณ  ๋ณธ์ธ์ด ๊ฐœ์ธ์ ์œผ๋กœ ์ดํ•ด๊ฐ€ ๋˜์ง€ ์•Š๋Š” ๋ถ€๋ถ„์ด ๋งŽ์•„ ๋‚˜์ค‘์— ๋‹ค์‹œ ๊ตฌํ˜„ํ•  ๊ฒฝ์šฐ๋ฅผ ๋Œ€๋น„ํ•ด ๊ธ€๋กœ ์ž‘์„ฑํ•˜๊ธฐ๋กœ ๋งˆ์Œ์„ ๋จน์—ˆ์Šต๋‹ˆ๋‹ค. ๋ถ€์กฑํ•œ ๋‚ด์šฉ์ด ์žˆ์„ ์ˆ˜ ์žˆ์ง€๋งŒ ๋” ์ข‹์€ ๋‚ด์šฉ์ด ์žˆ๋‹ค๋ฉด ๋Œ“๊ธ€๋กœ ๋‹ฌ์•„์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์ข‹์€ ํ”ผ๋“œ๋ฐฑ์€ ์–ธ์ œ๋‚˜ ํ™˜์˜์ด๋ฉฐ, ์ œ ๊ธ€์ด ์†Œ์…œ๋กœ๊ทธ์ธ์„ ๊ตฌํ˜„ํ•˜๋ ค๋Š” ๋ˆ„๊ตฐ๊ฐ€์—๊ฒŒ ์ข‹์€ ๋„์›€์ด ๋˜์—ˆ์œผ๋ฉด ํ•ฉ๋‹ˆ๋‹ค. ๊ธ€์˜ ์ง„ํ–‰์€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ˆœ์„œ๋กœ ์ด์–ด์งˆ ์˜ˆ์ •์ž…๋‹ˆ๋‹ค. 1. ๋ฐฐ๊ฒฝ์ง€์‹ ์ดํ•ดํ•˜๊ธฐ, ์ „์ฒด ๊ทธ๋ฆผ ์‚ดํŽด๋ณด๊ธฐ (OAuth2, JWT Token, ํ”„๋กœ์ ํŠธ ์ „์ฒด ๋„์‹ํ™”) 2. Naver, Kakao, Google์— ํ”„๋กœ์ ํŠธ๋ฅผ OAuth2 Client๋กœ..

    [TS] Spring Security + Spring OAuth2 Client ์ ์šฉ ๊ณผ์ • ์ค‘ ๋ฐœ์ƒํ•œ ๋ฌธ์ œ ํŠธ๋Ÿฌ๋ธ” ์ŠˆํŒ…

    [TS] Spring Security + Spring OAuth2 Client ์ ์šฉ ๊ณผ์ • ์ค‘ ๋ฐœ์ƒํ•œ ๋ฌธ์ œ ํŠธ๋Ÿฌ๋ธ” ์ŠˆํŒ…

    ๐Ÿค” ์˜ค๋ฅ˜ ๋ฐœ์ƒ ์ƒˆ๋กœ์šด ํ† ์ด ํ”„๋กœ์ ํŠธ, NEO๋ฅผ ๊ฐœ๋ฐœํ•˜๋ฉด์„œ ์†Œ์…œ ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ ๊ตฌํ˜„์„ ์œ„ํ•ด OAuth2 Client ๊ฐœ๋ฐœ์„ ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ฐœ๋ฐœ์ด ๋๋‚œ ํ›„, API ์š”์ฒญ์„ ํ†ตํ•ด ํ•ด๋‹น ๊ธฐ๋Šฅ์„ ๊ฒ€ํ† ํ•˜๋Š” ๋„์ค‘ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ƒ์— OAuth2 ์ธ์ฆ ๊ณผ์ •์„ ์ง„ํ–‰ํ•œ ์ดํ›„ ์ƒˆ๋กœ์šด ํšŒ์› ๊ฐ€์ž… ๋ฐ์ดํ„ฐ๊ฐ€ ์ €์žฅ๋˜์ง€ ์•Š๋Š” ์ด์ƒํ•œ ํ˜„์ƒ์„ ๋ฐœ๊ฒฌํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ๋ฌธ์ œ๋ผ๋ฉด, ๋ถ„๋ช… ๋กœ๊ทธ๊ฐ€ ์ž‘์„ฑ๋˜์—ˆ์„ํ…๋ฐ, ํ•ด๋‹น ๋กœ๊ทธ๊ฐ€ ์—†๋Š” ๊ฒƒ๋„ ์ด์ƒํ•ด ๋ฌธ์ œ์˜ ์›์ธ์„ ํŠธ๋ž˜ํ‚นํ–ˆ์Šต๋‹ˆ๋‹ค. OAuth2 ์ธ์ฆ ๊ณผ์ • ์ค‘, ์‚ฌ์šฉ์ž์˜ ์ •๋ณด๋ฅผ ์–ป์–ด์™€ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์— ์ €์žฅํ•˜๋Š” ์ฝ”๋“œ๋Š”, OAuth2UserService๋ฅผ implementํ•œ NEOOAuth2UserService์— ์žˆ์Šต๋‹ˆ๋‹ค. @Slf4j @Service @RequiredArgsConstructor public ..

    [Trouble Shooting] Lombok ์‚ฌ์šฉ์‹œ, ์–ด๋…ธํ…Œ์ด์…˜์ด ์ ์šฉ๋˜์ง€ ์•Š๋Š” ๊ฐ„๋‹จํ•œ ๋ฌธ์ œ ํ•ด๊ฒฐ

    [Trouble Shooting] Lombok ์‚ฌ์šฉ์‹œ, ์–ด๋…ธํ…Œ์ด์…˜์ด ์ ์šฉ๋˜์ง€ ์•Š๋Š” ๊ฐ„๋‹จํ•œ ๋ฌธ์ œ ํ•ด๊ฒฐ

    Lombok์„ ์‚ฌ์šฉํ•ด ๋งŽ์€ ๋ณด์ผ๋Ÿฌ ํ”Œ๋ ˆ์ดํŠธ ์ฝ”๋“œ๋ฅผ ์ค„์ด๊ณ  ์žˆ๋‹ค. @RequiredConstructor์™€ @Builder, @Getter๋“ฑ ๋งŽ์€ ๋„์›€์„ ์ฃผ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ด๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ iDE ์ƒ์—์„œ๋Š” ์ •์ƒ์ ์œผ๋กœ ์ธ์‹์ด ๋˜์ง€๋งŒ, ๋นŒ๋“œ ๋ฐ ์ปดํŒŒ์ผ์„ ํ•˜๋ฉด ํ•ด๋‹น ๋ฉ”์†Œ๋“œ๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†๋‹ค๋Š” ๊ธฐ์ดํ•œ ๋ฌธ์ œ์˜€๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, @RequiredConstructor๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด IDE ์ƒ์—๋Š” ๋ฌธ์ œ ์—†๋Š” ์ฝ”๋“œ๋ฅผ ์ž˜ ์ž‘์„ฑํ–ˆ์ง€๋งŒ, ์ด์™€ ๊ฐ™์ด ์ƒ์„ฑ์ž๋Š” ์•„๋ฌด๋Ÿฐ ์ธ์ž๋ฅผ ์›ํ•˜์ง€ ์•Š๋Š”๋‹ค๋Š” ์˜ค๋ฅ˜๊ฐ€ ๋‚˜์™”๋‹ค. ์‹ค๋งˆ๋ฆฌ๋ฅผ ํ‘ธ๋Š” ๊ณผ์ •์—์„œ, ์ง์ ‘ ์†์œผ๋กœ ๋ชจ๋“  ์ธ์ž์— ๋Œ€ํ•œ Constructor๋ฅผ ์ƒ์„ฑํ•˜๋‹ˆ ์˜ค๋ฅ˜๊ฐ€ ์ œ๊ฑฐ๋˜์—ˆ๋‹ค๋Š” ์ ๊ณผ, ๋‹จ์ˆœํžˆ @RequiredArgsConstructor ์™ธ์—๋„ @Getter์™€ ๊ฐ™์€ ๋‹ค๋ฅธ ๋กฌ๋ณต ์–ด๋…ธํ…Œ์ด์…˜์— ๋Œ€ํ•ด์„œ๋„ ๋™์ผํ•œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ..