Backend Language

๊ทธ ์ „๊นŒ์ง€๋Š” api์—์„œ ์ง์ ‘ userid๋ฅผ ๊ฑด๋‚ด๊ณ  JPA CRUD FindByUserId๋ฅผ ํ†ตํ•ด ์œ ์ €์˜ ์ •๋ณด๋ฅผ ๋ถˆ๋Ÿฌ์™”์—ˆ๋‹ค. ํ•˜์ง€๋งŒ ํšŒ์›๊ฐ€์ž…์„ ํ•˜๊ณ , ๋กœ๊ทธ์ธ์„ ํ•˜๊ฒŒ ๋˜๋ฉด token์„ ์ œ๊ณตํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ UMC APP API๋ฅผ ํŒ€์›๋ถ„๊ป˜์„œ ์ƒ์„ฑํ•ด์ฃผ์…จ๋‹ค. ๊ทธ๋ ‡๋‹ค๋ฉด, token(authorization์— ์žˆ๋Š”)๋ฅผ ๊ณ„์† ์‚ฌ์šฉํ•ด์„œ json์„ ๋ฐ›์•„์™€์•ผํ•˜๋Š” ์ƒํ™ฉ์—์„œ๋Š” userId๋ฅผ ๋ณด๋‚ด์ง€ ์•Š๊ณ  jwt๋ฅผ ํ†ตํ•ด์„œ ์ •๋ณด๋ฅผ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ์ง€ ์•Š์„๊นŒํ•˜๋Š” ์˜๋ฌธ์ด ๋“ค์—ˆ๋‹ค. ์ด์— ๋ฐœ๊ฒฌํ•˜๊ฒŒ ๋œ 3๊ฐ€์ง€ ๋ฐฉ๋ฒ• ์ค‘, ๐Ÿ’ป๋™์•„๋ฆฌ ์•ฑ ํ”„๋กœ์ ํŠธ์—์„œ๋Š” Principal์„ ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค. (@AuthenticationPrincipal ์ด๋‚˜ SecurityContextHolder, Authentication ๋ชจ๋‘ ์‚ฌ์šฉํ–ˆ๋Š”๋ฐ ์—๋Ÿฌ ๋‚จ,, ์ด์œ ๋ฅผ ๋ชจ๋ฅด๊ฒ ์›€,,..
Repository์—์„œ findBy ์ž‘์„ฑํ•˜๊ณ , ์ดํ›„์— List๋ฅผ ํ†ตํ•ด ๊ฐ’์„ ๋ชจ๋‘ ๋ถˆ๋Ÿฌ์˜ฌ ๋•Œ ๋ชจ๋“  ๊ฐ’์ด ๋ถˆ๋Ÿฌ์ ธ์˜ค๊ฒŒ ๋œ๋‹ค. ํ•˜์ง€๋งŒ, User์™€ ๊ฐ™์€ ๊ฒฝ์šฐ์—๋Š” ๊ฐœ์ธ ์ •๋ณด๊ฐ€ ๊ฐ™์ด ๋ถˆ๋Ÿฌ์ ธ์˜ค๊ฒŒ ๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์–ด์„œ ์ด๋ฅผ ๋ฐฉ์ง€ํ•˜๊ณ ์žํ•œ๋‹ค. ๋ชจ๋“  ๊ฐ’์ด ๋ถˆ๋Ÿฌ์ ธ์˜ค๊ฒŒ ๋˜๋Š” ๊ฒฝ์šฐ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. @Getter @Entity @NoArgsConstructor @Table(name="user") public class UserEntity{ @Id @GeneratedValue private Long userIdx; @Column(nullable = false, length = 100) private String nickName; @Column(nullable = false, length = 100) private String user..
Spring boot์—์„œ Entity๋ฅผ ์ƒ์„ฑํ•œ ํ›„, @Setter๋ฅผ ํ†ตํ•ด setter ํ•จ์ˆ˜๋ฅผ ์ƒ์„ฑํ•˜๊ฒŒ ๋˜๋ฉด ๋‹ค๋ฅธ class์—์„œ๋„ ์ •๋ณด๋ฅผ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๊ธฐ์— ๋ณด์•ˆ์ ์œผ๋กœ๋„ ์ข‹์ง€ ์•Š๋‹ค. (์‚ฌ์šฉ์€ ๊ฐ€๋Šฅํ•˜์ง€๋งŒ, ์ง€์–‘ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.) ๊ทธ๋ ‡๋‹ค๋ฉด @Setter ๋Œ€์‹ ์— ์ •๋ณด๋ฅผ ๋ณ€๊ฒฝํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ์–ด๋–ค ๊ฒƒ์„ ์‚ฌ์šฉํ•ด์•ผ ํ• ๊นŒ? @Getter @Entity @NoArgsConstructor @Table(name="user") public class UserEntity{ @Id @GeneratedValue private Long userIdx; @Column(nullable = false, length = 100) private String nickName; @Column(nullable = false, length = 100) p..
๐Ÿ’ปUMC ํ™œ๋™์„ ํ•˜๋ฉด์„œ JPA๋กœ Database DML ์ž‘์—…์„ ํ•˜๋˜ ์ค‘, @Id ์–ด๋…ธํ…Œ์ด์…˜์„ ํ•œ ํด๋ž˜์Šค์— ์—ฌ๋Ÿฌ๊ฐœ๋ฅผ ์ž‘์„ฑํ•˜๋‹ˆ ์˜ค๋ฅ˜๊ฐ€ ๋‚ฌ๋‹ค๐Ÿ˜ฉ ๊ตฌ๊ธ€๋ง ํ•ด๋ณด๋‹ˆ, 2๊ฐœ ์ด์ƒ์˜ composite primary key์—์„œ๋Š” @IdClass ํ˜น์€ @EmbeddedId๋ฅผ ์‚ฌ์šฉํ•ด์•ผํ•œ๋‹ค๊ณ  ํ•œ๋‹ค.....(๋ณต์žกํ•ด ์œผ์œ ๐Ÿ˜‘) ๋‚˜๋Š” ๊ทธ ์ค‘์—์„œ๋„ ๊ทธ๋‚˜๋งˆ ์ข€ ๊ฐ„๋‹จํ•ด๋ณด์˜€๋˜ @EmbeddedId๋ฅผ ์‚ฌ์šฉํ•ด๋ณด๊ณ ์ž ํ•œ๋‹ค..(์ €๋ฒˆ์— ๊ทธ๋ž˜๋„ ๊ณต๋ถ€ ํ•ด๋ด์„œ Embedded ๊ฐœ๋…์„ ์•Œ๊ธฐ์—,,) Course Strong Entity์™€ Section Week Entity๊ฐ€ ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ด๋ณด์ž. Section table์—์„œ๋Š” ์ž์‹ ์„ ๋‚˜ํƒ€๋‚ด๋Š” identifier attribute์™€ Course์˜ PK๊ฐ€ ๋ชจ๋‘ PK๋กœ ์ €์žฅ๋˜๋Š” Composite PK ์ผ ๊ฒƒ์ด๋‹ค. ์ด..
1. ์—ฐ๊ด€๊ด€๊ณ„ ์–ด๋…ธํ…Œ์ด์…˜ -> [์ถœ์ฒ˜] one to one: ์ผ๋Œ€์ผ ๋งคํ•‘ one to many: ์ผ๋Œ€๋‹ค ๋งคํ•‘ many to one: ๋‹ค๋Œ€์ผ ๋งคํ•‘ 2. Many to One Mapping User์™€ OrderLine์ด 1:n์˜ ๊ด€๊ณ„์ด๋ฉด, OrderLine Table์— @ManyToOne ์–ด๋…ธํ…Œ์ด์…˜์„ ์ž‘์„ฑํ•ด์•ผ ํ•œ๋‹ค. @ManyToOne(fetch = FetchType.LAZY) FetchType.EAGER [์ฆ‰์‹œ๋กœ๋”ฉ]๋Š” ์—ฐ๊ด€๋œ ์—”ํ„ฐํ‹ฐ๋ฅผ ๋ฐ”๋กœ ์กฐํšŒํ•œ๋‹ค. ์‹ค์ œ ๊ฐ์ฒด๊ฐ€ ์‚ฌ์šฉ๋˜์ง€ ์•Š๋”๋ผ๋„ ์กฐํšŒ๋ฅผํ•œ๋‹ค. FetchType.LAZY [์ง€์—ฐ๋กœ๋”ฉ]์€ ์‹ค์ œ ์‚ฌ์šฉ ์‹œ์ ์— ์กฐํšŒํ•œ๋‹ค. @JoinColumn(name="FK") ์™ธ๋ž˜ํ‚ค ๋งคํ•‘์‹œ ์‚ฌ์šฉ @ManyToOne(optional =True) : FK๋Š” Null (Total par..
UMC ์•ฑ ๋Ÿฐ์นญ ํ”„๋กœ์ ํŠธ์—์„œ JPA๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ๋กœํ–ˆ๋‹ค. Jdbc๋Š” ์‚ฌ์šฉํ•ด๋ดค์ง€๋งŒ, JPA๋Š” ์ฒ˜์Œ์ด๊ธฐ ๋•Œ๋ฌธ์— ๊ณต๋ถ€ํ•ด๋ณด๊ณ ์ž ํ•œ๋‹ค. (Jdbc ์‚ฌ์šฉ๋ณด๋‹ค, Jpa ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ ์ •๋ง ๊น”๋”ํ•ด๋ณด์˜€๋‹ค. ๊ทผ๋ฐ JPA๊ฐ€ ์ข€ ๋” ์–ด๋ ค์›Œ ๋ณด์—ฌ,,,,,) ์˜ค๋Š˜ ๊ณต๋ถ€ํ•  ๋‚ด์šฉ์€ ๋ฐ”๋กœ, JPA๋กœ Spring boot์— Entity ์ƒ์„ฑํ•˜๊ณ  ๊ด€๊ณ„ ์„ค์ •ํ•˜๋Š” ๊ฒƒ!! 1. JPA: ORM(Object Relational Mapping) Framework ORM์€ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์™€ ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๊ฐ€ ์„œ๋กœ ํ˜ธํ™˜๋˜์ง€ ๋˜๋„๋ก ๋ฐ์ดํ„ฐ๋ฅผ ๋ณ€๊ฒฝํ•ด์ฃผ๋Š” ๊ฒƒ์„ ์˜๋ฏธ ๊ฐ€์ƒ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ๊ตฌ์ถ•ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด์ฃผ๋Š” ๊ฒƒ 2. Spring boot ์—์„œ์˜ JPA ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค ์—”์ง„ -> H2 Database JPA ์„ค์ • Lombok ์„ค์ • -> JPA ์„ค์ •๋ถ€ํ„ฐ Lo..
โ€ป ํ•ด๊ฒฐ ๋‚ด์šฉ์€ ๋งจ ๋งˆ์ง€๋ง‰์— ์žˆ์Œ โ€ป ๊ฐ์ฒด์ง€ํ–ฅ์ ์‚ฌ๊ณ ์™€ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ˆ˜์—…์„ ๋“ฃ๋˜ ์ค‘ ์ด์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค. ๊ต์ˆ˜๋‹˜์ด ์„ค๋ช…ํ•ด์ฃผ์‹  ์ฝ”๋“œ๋ฅผ ๋˜‘๊ฐ™์ด ์ž‘์„ฑํ–ˆ๋Š”๋ฐ, ๋‚˜๋งŒ ์ด๋Ÿฐ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ ๊ฒƒ์ด๋‹ค. ํŠนํžˆ @RestController๋ฅผ ์ฃผ์„์ฒ˜๋ฆฌ ํ•ด์ œํ•˜๊ณ  ์ง„ํ–‰ํ–ˆ๋”๋‹ˆ ๋ฐœ์ƒํ•œ ์˜ค๋ฅ˜์˜€๋‹ค,,, ( ๊ทธ ์ „์—๋Š” ์ž˜๋งŒ ๋๋Š”๋ฐ,, ์™œ๊ทธ๋ ค,,) ์˜ค๋ฅ˜๋‚ด์šฉ์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2021-12-02 13:15:47.039 ERROR 28612 --- [ main] o.s.boot.SpringApplication : Application ru..
ํ•™๊ต์—์„œ DB ์„ค๊ณ„ ๋ฐ ๊ตฌํ˜„2 ์ˆ˜์—…์„ ๋“ค์œผ๋ฉด์„œ Oracle DBMS๋กœ ์‹ค์Šต์„ ์ง„ํ–‰ํ•˜๊ณ ์ž ํ•˜์˜€๋‹ค. Oracle DBMS๋ฅผ ์„ค์น˜ํ•˜๋Š” ๊ณผ์ • ์†์—์„œ ํ•˜๋‚˜์˜ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค. 'ํŒŒ์ผ์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.' ๋ผ๋Š” ๋ฌธ๊ตฌ์™€ ํ•จ๊ป˜ ์„ค์น˜ ์˜ค๋ฅ˜๊ฐ€ ๋‚œ ๊ฒƒ์ด๋‹ค. ์ด๋ฅผ ๋Œ€์ˆ˜๋กญ๊ฒŒ ์ƒ๊ฐํ•˜์ง€ ์•Š๊ณ  ๊ฑด๋„ˆ๋›ฐ๊ธฐ๋ฅผ ํ•˜๋ฉด์„œ ์„ค์น˜๋ฅผ ์ง„ํ–‰ํ•˜๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ, ๊ตฌ๊ธ€๋ง์„ ํ•˜๋‹ˆ ์ด ๊ฒƒ์„ ๊ฑด๋„ˆ ๋›ฐ๊ณ  ํ•˜๋ฉด ์‹ค์Šต์„ ํ•  ๋•Œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ๋˜์–ด ์žˆ์—ˆ๋‹ค. ๋˜ํ•œ 44%์—์„œ ์„ค์น˜ ์ง„ํ–‰์ด ๋ฉˆ์ถฐ์„œ ์„ค์น˜๊ฐ€ ๋˜์ง€ ์•Š์•˜๋‹ค. ์ƒ๊ฐ์„ ํ•ด๋ณด๋‹ˆ, ๋‘ ํŒŒ์ผ์„ ์••์ถ• ํ•ด์ œํ•  ๋•Œ ๊ต์ˆ˜๋‹˜๊ป˜์„œ 'ํ•˜๋‚˜์˜ ๊ฒฝ๋กœ๋กœ ๋งŒ๋“œ์„ธ์š”'๋ผ๋Š” ๋ง์„ ์ƒ๊ฐํ•˜์ง€ ์•Š๊ณ  ๊ฐ์ž ๋”ฐ๋กœ๋”ฐ๋กœ ๋„ฃ์–ด๋†จ์—ˆ๋‹ค.. ์ด ๋‘ ์••์ถ• ํŒŒ์ผ์„ ํ•ด์ œํ•˜๋ฉด ํŒŒ์ผ ์•ˆ์— 'database' ํŒŒ์ผ์ด ์žˆ์„ ๊ฒƒ์ด๋‹ค. V77408-01_2of2์˜ dat..
ํ•™๊ต ์ „๊ณต ์ˆ˜์—… ์‹œ๊ฐ„์— Sping boot๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด์„œ, Httpie๋ฅผ ์„ค์น˜๋ฅผ ํ•ด์•ผ๋งŒ ํ–ˆ๋‹ค. Mac OS์—์„œ๋Š” ๋‹ค์šด๋กœ๋“œ๊ฐ€ ์‰ฝ์ง€๋งŒ, Winodw OS์—์„œ๋Š” Python์ด ์„ค์น˜๋˜์–ด ์žˆ์ง€ ์•Š์•„ ์„ค์น˜๊ฐ€ ์šฉ์ดํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— Winodw OS์—์„œ Httpie๋ฅผ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ž‘์„ฑํ•˜๊ณ ์ž ํ•œ๋‹ค. https://luji.tistory.com/99 httpie Windows์—์„œ ์„ค์น˜ํ•˜๊ธฐ httpie๋ž€? ํŒŒ์ด์„ ์—์„œ ๊ฐœ๋ฐœ๋œ ์œ ํ‹ธ๋ฆฌํ‹ฐ๋กœ http ๊ฐœ๋ฐœ์ด๋‚˜ ๋””๋ฒ„๊น… ์šฉ๋„๋กœ ์‚ฌ์šฉ๋œ๋‹ค. ์‚ฌ์šฉ์„ฑ์ด ์‰ฌ์šฐ๋ฉด์„œ json์ด ๋‚ด์žฅ๋˜์–ด์žˆ๋‹ค. ๊ฐ€๋…์„ฑ์ด ๋›ฐ์–ด๋‚˜๋ฉฐ ๊ธฐํƒ€ ์žฅ์ ๋“ค์ด ์žˆ์Œ. ๋ณดํ†ต ๋ฆฌ๋ˆ…์Šค๋‚˜ ๋งฅ์—์„  yum, apt, bre luji.tistory.com ์ด ๋ธ”๋กœ๊ทธ๋ฅผ ํ†ตํ•ด์„œ Httpie ์„ค์น˜๋ฅผ ์ง„ํ–‰ํ–ˆ๋‹ค. 1. ๋ฐ‘ ๋งํฌ์— ๋“ค์–ด๊ฐ€์„œ Python์„ ..
โ€ปํ•ด๊ฒฐ ๋ฐฉ๋ฒ•๋ถ€ํ„ฐ ๋ณด๊ณ  ์‹ถ์€ ์‚ฌ๋žŒ๋“ค์€ ๋ฐ”๋กœ ๋งˆ์ง€๋ง‰์œผ๋กœ ๋‚ด๋ ค๊ฐ€์„ธ์š”!!โ€ป ํ•™๊ต ์ˆ˜์—…์—์„œ ์ง„ํ–‰ํ•˜๋Š” Spring boot ๊ณผ์ œ ์‹œํ–‰ ์‹œ, ์ด์™€ ๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค. 2021-11-08 16:02:17.715 ERROR 9912 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Field cart in com.example.PetAppMidterm.Application required a bean of type 'com.example.PetAppMidterm.PetRepository' that c..
chaerlo127
'Backend Language' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (3 Page)