728x90 ๋ฐ์ํ Spring๐23 [SpringBoot] ๋๊ธ API ๊ตฌํํ๊ธฐ ๋๊ธ api ๊ตฌํํ๊ธฐ ๊ฒฐ๊ณผ ์ํฐํฐ(Entity) > ํ์ผ๋ช : Coment.java import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @Getter @Setter @AllArgsConstructor @NoArgsConstructor @Entity @Table(name = "noticeComment") public class Comment { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @ManyToOne(fetch = F.. 2024. 4. 4. ID์์ฑ ์ NAME ์์ฑ ํ๋ก ํธ์๋ ์ ๋ฐฑ์๋ ์ฐ๋ฆฌ๋ ํํ ํ๋ก ํธ ์๋๋ผ๊ณ ํ๋ฉด HTML, CSS , JavaScript ๋ก ์๊ณ ์๊ณ , ๋ฐฑ์๋๋ผ๊ณ ํ๋ฉด Controller , Service, Repository, Dto , Entity ๋ก ์๊ณ ์๋ค. ์ค๋์ ๋์ณ์๋ ์๋ ๊ธฐ๋ณธ ์ง์์ธ ID ์ NAME ์์ฑ์ ๋ํด ์ ๋ฆฌํ๊ณ ์ ํ๋ค. ํ๋ก ํธ์๋์์ ๋ฐฑ์๋๋ก ๋ฐ์ดํฐ๋ฅผ ์ ๋ฌํ ๋ ๋ฐฑ์๋์์๋ ํ๋ก ํธ์๋์ ์ด๋ค ์์ฑ์ ๋ฐ๋ผ๋ณด๊ณ ์ ๊ทผํ๋์ง ํท๊ฐ๋ คํ๋๋ฐ, ๊ฒฐ๋ก ๋ถํฐ ๋งํ์๋ฉด, name ์์ฑ์ ๊ธฐ๋ฐ์ผ๋ก ์ ๊ทผํ๋ค. ์ฌ๊ธฐ ์๋ ์์ฃผ ํ๋ฒํ ๋ ์จ API ๋ฅผ ๊ฐ๋ฐํ๊ธฐ ์ํ HTML ์ฝ๋๊ฐ ์๋ค. ์๋๋ ํด๋น HTML ๋ก๋ถํฐ ๋ฐ์ดํฐ๋ฅผ ์ ๋ฌ ๋ฐ์ ๋ฐฑ์๋-controller ์ด๋ค. ์ปจํธ๋กค๋ฌ์์๋ ์ฃผ๋ก @RequestParam ์ด๋ ธํ ์ด์ ์ ์ฌ์ฉํ์ฌ ํ๋ก ํธ์.. 2024. 4. 3. Controller vs @Restcontroller ์ฐจ์ด์ @Controller vs @Restcontroller ์ฐจ์ด์ Spring์์ Controller ๋ฅผ ์ง์ ํด์ฃผ๊ธฐ ์ํ ์ด๋ ธํ ์ด์ (@)์ @Controller ์ @RestController๊ฐ ์์ต๋๋ค. ์ ํต์ ์ธ Spring MVC์ Controller์ธ @Controller์ restful ์น ์๋น์ค์ ์ปจํธ๋กค๋ฌ์ธ @RestController์ ์ฃผ์ํ ์ฐจ์ด์ ์ HTTP Response Body๊ฐ ์์ฑ๋๋ ๋ฐฉ์์ ๋๋ค. ํ๋ก์ ํธ ์งํ ์ค ์ฐจ์ด์ ์ ๋ํด ๊ถ๊ธํ์ฌ ์ ๋ฆฌํด๋ณด์์ต๋๋ค. ํ๋ฉด์ ํ๊ธฐํ๋ ค๋ฉด restcontroller๊ฐ ๋๋ฉด ์๋๊ณ controller๊ฐ ๋์ผ ํจ rest๋ก ํ๋ฉด return json์ผ๋ก ๋๊ธฐ ๋๋ฌธ —- by.๊ตฌ๊ธ๋ง ๋ค์ด๊ฐ๊ธฐ ์์ Controller ๊ฐ ๋ญ์ง ๋ถํฐ!! 1. @Controlle.. 2024. 3. 18. ORM, JPA, MyBatis ์์์ฑ(Persistence) ๋ฑ์ฅ! ๋ฐ์ดํฐ๋ค์ด ํ๋ก๊ทธ๋จ์ด ์ข ๋ฃ๋์ด๋ ์ฌ๋ผ์ง์ง ์๊ณ ์ด๋ค ๊ณณ์ ์ ์ฅ๋๋ ๊ฐ๋ ์ ์์์ฑ(Persistence) ์ด๋ผ๊ณ ํ๋ค. Issue_1 ์๋ฐ์์ ๋ฐ์ดํฐ์ ์์์ฑ์ ์ํ JDBC ๋ฅผ ์ง์ํด์ฃผ๋๋ฐ, ์ด๋ ๋งคํ ์์ ์ ๊ฐ๋ฐ์๊ฐ ์ผ์ผ์ด ์ํํด์ผ ํ๋ ๋ฒ๊ฑฐ๋ก์์ด ์๋ค. SQL Mapper ์ ORM ์ ๋ฑ์ฅ! SQL Mapper ์ **ORM**์ ๊ฐ๋ฐ์๊ฐ ์ง์ JDBC Programming ์ ํ์ง ์๋๋ก ๊ธฐ๋ฅ์ ์ ๊ณตํด์ฃผ๋ Persistence Framework ์ข ๋ฅ์ด๋ค. Issue_2 ๊ธฐ์กด JDBC ๋ง์ ์ฌ์ฉ์ผ๋ก ์ฟผ๋ฆฌ ๋ฌธ์ ๋ง๋ค์ด ์์ฒญํ๋ ๊ณผ์ ์ ์ฟผ๋ฆฌ ๋ฌธ์ด ์กฐ๊ธ๋ง ๊ธธ์ด์ ธ๋ ๊ด๋ฆฌ๊ฐ ํ๋ค๊ณ ๋ฒ๊ฑฐ๋กญ๋ค. JPA , MyBatis ๋ฑ์ฅ! ๋ฐ๋ผ์ JPA ์ MyBatis ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ.. 2024. 3. 12. ์ด์ 1 2 3 4 ยทยทยท 6 ๋ค์ 728x90 ๋ฐ์ํ