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

spring43

Spring - ํšŒ์›๊ด€๋ฆฌ์˜ˆ์ œ (ํšŒ์› ์„œ๋น„์Šค ๊ฐœ๋ฐœ) package hello.hellospring.service; import hello.hellospring.domain.Member; import hello.hellospring.repository.MemberRepository; import hello.hellospring.repository.MemoryMemberRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.Optional; //์–ด๋…ธํ…Œ์ด์…˜ ๋“ฑ๋ก์„ ์•ˆํ•˜๋ฉด ๊ทธ์ € ์ˆœ์ˆ˜ ์ž๋ฐ”์ผ๋ฟ... //@Service public c.. 2023. 7. 4.
Spring - ํšŒ์›๊ด€๋ฆฌ์˜ˆ์ œ (ํ…Œ์ŠคํŠธ์ผ€์ด์Šค ์ž‘์„ฑ) ์ž๋ฐ”๋Š” JUnit์ด๋ผ๋Š” ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ์ด์šฉํ•ด์„œ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ฝ”๋“œ ํ…Œ์ŠคํŠธ๊ฐ€ ๊ฐ€๋Šฅํ•˜๋‹ค. package hello.hellospring.repository; import hello.hellospring.domain.Member; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import java.util.List; import static org.assertj.core.api.Assertions.*; public class MemoryMemberRepositoryTest { MemoryMemberRepository repository = new MemoryMemberRepository(); @AfterEach //๊ฐ ํ•จ์ˆ˜๊ฐ€ ๋๋‚ .. 2023. 7. 4.
Spring - ํšŒ์›๊ด€๋ฆฌ์˜ˆ์ œ (ํšŒ์› ๋„๋ฉ”์ธ๊ณผ ๋ ˆํฌ์ง€ํ† ๋ฆฌ) ํšŒ์› ๊ฐ์ฒด (./domain/Member.java) package hello.hellospring.domain; public class Member { private Long id; private String name; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } ํšŒ์› ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ์ธํ„ฐํŽ˜์ด์Šค (./repository/MemberRopository.java) package hello.hellospring.repository; import .. 2023. 7. 4.
Spring - ์›น๊ฐœ๋ฐœ๊ธฐ์ดˆ 1. ์ •์  ์ปจํ…์ธ  controller๋กœ ๋”ฐ๋กœ ์ฃผ์†Œ๊ฐ’์„ ๋งคํ•‘ํ•ด์ฃผ์ง€ ์•Š์•„๋„, staticํด๋”์— a.html๋กœ ์ €์žฅ์„ ํ–ˆ๋‹ค๋ฉด, /a ์ฃผ์†Œ๋ฅผ ์ณค์„๋•Œ ํ•ด๋‹น html์ด ๋œจ๊ฒŒ ๋œ๋‹ค. 2. MVC์™€ ํ…œํ”Œ๋ฆฟ ์—”์ง„ MVC: Model, View, Controller view๋Š” ๋ˆˆ์— ๋ณด์ด๋Š”๊ฒƒ๋งŒ ๊ด€๋ฆฌํ•œ๋‹ค. html์— ๊ฐ’์„ ๋„˜๊ธธ๋•Œ ์‚ฌ์šฉ 3. API ์„œ๋ฒ„์™€ ์•ฑ(์•ˆ๋“œ๋กœ์ด๋“œ, ios)์™€ ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›์„๋•Œ ์„œ๋ฒ„์™€ ์„œ๋ฒ„๋ผ๋ฆฌ ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›์„๋•Œ @ResponseBody ๋ฅผ ์‚ฌ์šฉ -> json ํ˜•์‹์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ˜ํ™˜ HTTP์˜ BODY์— ๋ฌธ์ž ๋‚ด์šฉ์„ ์ง์ ‘ ๋ฐ˜ํ™˜(์‘๋‹ต) -> html์„ ๊ฑฐ์น˜์ง€ ์•Š์Œ viewResolver ๋Œ€์‹ ์— HttpMessageConverter ๊ฐ€ ๋™์ž‘ ๊ธฐ๋ณธ ๋ฌธ์ž์ฒ˜๋ฆฌ: StringHttpMessageConverter.. 2023. 7. 3.