๋ฐ˜์‘ํ˜•

Error Logs๐Ÿพ 17

Mapper ์—๋Ÿฌ

๋ฌธ์ œ DTO์™€ ์—”ํ‹ฐํ‹ฐ๋ฅผ ๋งคํ•‘ํ•˜๊ธฐ์œ„ํ•ด์„œ mapstruct๋ฅผ ์‚ฌ์šฉํ–ˆ๋Š”๋ฐ ๊ณ„์†ํ•ด์„œ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค. ์ด๋Ÿฐ์‹์œผ๋กœ userName๊ณผ email์„ ์–‘์ชฝ์—์„œ ์ฐพ์•„์™€์„œ ์•Œ์•„์„œ ๋งคํ•‘์„ ํ•ด์ค˜์•ผ ๋˜๋Š”๋ฐ ์ •๋ง ์ด์ƒํ•˜๊ฒŒ๋„ Member์˜ ๋””ํดํŠธ ์ƒ์„ฑ์ž๊ฐ€ ์—†๋Š”๋ฐ๋„ new Member(); ์ด๋Ÿฐ์‹์œผ๋กœ meber๋ฅผ ๋ฆฌํ„ดํ•ด์คฌ๋‹ค. ์ด๊ฒƒ์ €๊ฒƒ ์ ์šฉ์„ ํ•˜๋Š๋ผ๊ณ  ํ™•์‹คํžˆ ์–ด๋–ค๋ฌธ์ œ์ธ์ง€๋Š” ์ฐพ์•„๋‚ด์ง€๋ชปํ–ˆ์ง€๋งŒ ๊ฐ€์žฅ ์œ ๋ ฅํ•œ๊ฑด ๋กฌ๋ณต๊ณผ mapsturct์˜ dependencies ์ˆœ์„œ์ธ๊ฒƒ๊ฐ™๋‹ค. (์ข€๋” ํ™•์ธ์ด ํ•„์š”ํ•˜๋‹ค.) ๋กฌ๋ณต์ด mapstruct ๋ณด๋‹ค ๋’ค์— ์„ ์–ธ๋˜์–ด์žˆ์œผ๋ฉด ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ• ์ˆ˜๋„ ์žˆ๋‹ค๊ณ  ํ•˜๋Š”๋ฐ ํ™•์‹คํ•œ์ง€๋Š” ๋ชจ๋ฅด๊ฒ ๋‹ค. ์ฐธ๊ณ ์‚ฌํ•ญ 1. ๋ณ€ํ™˜๊ณผ์ •์—์„œ ๋ณ€ํ™˜ ์ „์˜ ๊ฐ์ฒด์—์„œ ๊ฐ’์„ ๊บผ๋‚ด์™€์•ผ ํ•˜๋ฏ€๋กœ ๋ณ€ํ™˜ ์ „ ๊ฐ์ฒด(source) ์—๋Š” Getter๊ฐ€ ์žˆ์–ด์•ผ ํ•œ๋‹ค. 2. ๋ณ€ํ™˜๊ณผ..

[Spring] javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.NotBlank'

@NotBlank @Email private String email; @NotBlank(message = "์ด๋ฆ„์€ 1๊ธ€์ž ์ด์ƒ ์ž…๋ ฅ๋˜์•ผํ•ฉ๋‹ˆ๋‹ค.") private String name; @Pattern(regexp = "^010-\\d{3,4}-\\d{4}$", message = "ํœด๋Œ€ํฐ ๋ฒˆํ˜ธ๋Š” 010์œผ๋กœ ์‹œ์ž‘ํ•˜๋Š” 11์ž๋ฆฌ ์ˆซ์ž์™€ '-'๋กœ ๊ตฌ์„ฑ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.") private String phone; @NotBlank private long password; ์œ„์™€ ๊ฐ™์ด Post์š”์ฒญ์— ๋Œ€ํ•œ DTO๋ฅผ ๊ตฌ์„ฑํ•˜์˜€๋Š”๋ฐ Post ์š”์ฒญ์‹œ์— ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค. javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constr..

[ํ…Œ์ŠคํŠธ] Junitํ…Œ์ŠคํŠธ ์ค‘ ์—๋Ÿฌ

๐Ÿ˜ŽError Log Gradle๋กœ Junit ์‹ค์Šต์„ ์ง„ํ–‰ํ•˜๋˜์ค‘ 2๊ฐœ์˜ ํ…Œ์ŠคํŠธ๊ฐ€ ์„ฑ๊ณต์€ ํ–ˆ๋Š”๋ฐ ๋กœ๊ทธ์ƒ์— ๋นจ๊ฐ„๊ธ€์”จ๋กœ org.junit.platform.launcher.core.EngineDiscoveryOrchestrator lambda$logTestDescriptorExclusionReasons$7 ์š”๋Ÿฐ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค... ์ฐพ์•„๋ณด๋‹ˆ ์ธํ…”๋ฆฌ์ œ์ด ์„ค์ •์ด ๋ฌธ์ œ์ธ๊ฒƒ ๊ฐ™์•˜๋‹ค. ๋นŒ๋“œ์‹œ์— Junit์œผ๋กœ ํ…Œ์ŠคํŠธ๊ฐ€ ์ง„ํ–‰๋˜์–ด์•ผํ•˜๋Š”๋ฐ Gradle๋กœ ๋˜์–ด์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค. ํ•ด๊ฒฐ๋ฐฉ๋ฒ• 1. Settings -> Build, Execution, Deployment -> Build Tools -> Gradle ์ด๋™ 2. Build and run using / Run tests using ์„ Intellij IDEA๋กœ ๋ณ€๊ฒฝ

[Spring] DTO validation ์ ์šฉ ์ค‘ ์˜ค๋ฅ˜

๐Ÿ˜ŽError Log DTO Validation ์ ์šฉ์ค‘์— ๋ฌธ์ž์—ด์˜ ๊ฒฝ์šฐ์— public class CoffeePostDto { @NotBlank(message = "ํ•œ๊ธ€์ด๋ฆ„์€ ๊ณต๋ฐฑ์ด ์•ˆ๋˜์š”.") @Pattern(regexp = "^[ใ„ฑ-ใ…Ž๊ฐ€-ํžฃ]+$") private String korName; @NotBlank(message = "์˜์–ด์ด๋ฆ„์€ ๊ณต๋ฐฑ์ด ์•ˆ๋˜์š”.") @Pattern(regexp = "^[A-Za-z]+( [A-Za-z]+)*$") private String engName; @Pattern(regexp = "^(1\d{2}|[2-4]\d{3}|50000)$") private Integer price; } ๋‹ค์Œ๊ณผ ๊ฐ™์€์‹์œผ๋กœ ์ ์šฉํ•˜์˜€๋Š”๋ฐ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค. ์œ„์˜ korName๊ณผ engName์˜ ๊ฒฝ์šฐ ..

[Error] String.isEmpty() / String.isBlank()

๐Ÿ˜ŽError Log ๋ฐ์ผ๋ฆฌ์ฝ”๋”ฉ ๋ฌธ์ œ๋ฅผ ํ’€๋˜์ค‘ if(element.isBlank())๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค. ๋กœ์ปฌ์—์„œ๋Š” ์ •์ƒ์ ์œผ๋กœ ๋Œ์•„๊ฐ”์ง€๋งŒ ์ฝ”ํ”Œ๋ฆฟ์—์„œ๋Š” ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค. ์ฐพ์•„๋ณด๋‹ˆ ์ž๋ฐ” ๋ฒ„์ „๋ฌธ์ œ์˜€๋‹ค..! isBlank()๊ฐ€ ์ž๋ฐ”11๋ถ€ํ„ฐ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•œ๊ฒƒ๋•Œ๋ฌธ... isBlank() : ์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด์ด ๋นˆ๋ฌธ์ž์—ด์ด๊ฑฐ๋‚˜, ๊ณต๋ฐฑ(" ")์„ ๊ฐ–๋Š” ๋ฌธ์ž์—ด์ด๋ฉด true, ์•„๋‹ˆ๋ฉด false isEmpty() : ์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด์ด ๋นˆ๋ฌธ์ž์—ด์ด๋ฉด true, ์•„๋‹ˆ๋ฉด false. String str1 = "strstr"; String str2 = " "; String str3 = ""; System.out.printf("empty? %b, blank? %b\n", str1.isEmpty(), str1.isBlank()); System.out.pri..

๋ฐ˜์‘ํ˜•