์ „์ฒด ๊ธ€

Spring/Spring ๊ธฐ๋ณธ

[์Šคํ”„๋ง ํ•ต์‹ฌ ์›๋ฆฌ - ๊ธฐ๋ณธํŽธ] - 8. ๊ด€์‹ฌ์‚ฌ์˜ ๋ถ„๋ฆฌ / AppConfig

๊ด€์‹ฌ์‚ฌ๋ฅผ ๋ถ„๋ฆฌํ•˜์ž ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํ•˜๋‚˜์˜ ๊ณต์—ฐ์ด๋ผ ์ƒ๊ฐํ•ด๋ณด์ž. ๊ฐ๊ฐ์˜ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋ฐฐ์—ญ(๋ฐฐ์šฐ ์—ญํ• )์ด๋ผ ์ƒ๊ฐํ•˜์ž. ๊ทธ๋Ÿฐ๋ฐ! ์‹ค์ œ ๋ฐฐ์—ญ ๋งž๋Š” ๋ฐฐ์šฐ๋ฅผ ์„ ํƒํ•˜๋Š” ๊ฒƒ์€ ๋ˆ„๊ฐ€ ํ•˜๋Š”๊ฐ€? ๋กœ๋ฏธ์˜ค์™€ ์ค„๋ฆฌ์—ฃ ๊ณต์—ฐ์„ ํ•˜๋ฉด ๋กœ๋ฏธ์˜ค ์—ญํ• ์„ ๋ˆ„๊ฐ€ ํ• ์ง€ ์ค„๋ฆฌ์—ฃ ์—ญํ• ์„ ๋ˆ„๊ฐ€ ํ• ์ง€๋Š” ๋ฐฐ์šฐ๋“ค์ด ์ •ํ•˜๋Š”๊ฒŒ ์•„๋‹ˆ๋‹ค. public class OrderServiceImpl implements OrderService { private final MemberRepository memberRepository = new MemoryMemberRepository(); // private final DiscountPolicy discountPolicy = new FixDiscountPolicy(); private final DiscountPolicy di..

Spring/Spring ๊ธฐ๋ณธ

[์Šคํ”„๋ง ํ•ต์‹ฌ ์›๋ฆฌ - ๊ธฐ๋ณธํŽธ] - 7. ์ƒˆ๋กœ์šด ํ• ์ธ ์ •์ฑ… ๊ฐœ๋ฐœ

์ƒˆ๋กœ์šด ํ• ์ธ ์ •์ฑ…์„ ํ™•์žฅํ•ด๋ณด์ž. ๊ฐ•์˜๋ฅผ ๋ณด๊ธฐ์ „์— ์Šค์Šค๋กœ ์ƒˆ๋กœ์šด ํ• ์ธ ์ •์ฑ… ( ์ •๋ฅ ํ• ์ธ ) ์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด ๋ณด์•˜๋‹ค. 1. RateDiscountPolicy ํด๋ž˜์Šค๋ฅผ ์ƒ์„ฑํ•˜๊ณ (๊ตฌํ˜„์ฒด ์ƒ์„ฑ) ์ด๊ฒƒ์€ DiscountPolicy Interface(์—ญํ• ) ๋ฅผ implements ํ•œ๋‹ค 2. RateDiscountPolicy ๊ตฌํ˜„์ฒด์˜ ๋ฉ”์„œ๋“œ๋ฅผ ์ž‘์„ฑํ•ด๋ณด์ž ( ์˜ค๋ฒ„๋ผ์ด๋”ฉ ) ์ฝ”๋“œ ๋”๋ณด๊ธฐ package hello2.demo.discount; import hello2.demo.member.Grade; import hello2.demo.member.Member; public class RateDiscountPolicy implements DiscountPolicy { private double DiscountRat..

Spring/Spring ๊ธฐ๋ณธ

[์Šคํ”„๋ง ํ•ต์‹ฌ ์›๋ฆฌ - ๊ธฐ๋ณธํŽธ] - 6. ์ฃผ๋ฌธ๊ณผ ํ• ์ธ ๋„๋ฉ”์ธ

์ฃผ๋ฌธ๊ณผ ํ• ์ธ ๋„๋ฉ”์ธ ์„ค๊ณ„ ์ฃผ๋ฌธ๊ณผ ํ• ์ธ ์ •์ฑ… ํšŒ์›์€ ์ƒํ’ˆ์„ ์ฃผ๋ฌธํ•  ์ˆ˜ ์žˆ๋‹ค. ํšŒ์› ๋“ฑ๊ธ‰์— ๋”ฐ๋ผ ํ• ์ธ ์ •์ฑ…์„ ์ ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ํ• ์ธ ์ •์ฑ…์€ ๋ชจ๋“  VIP๋Š” 1000์›์„ ํ• ์ธํ•ด์ฃผ๋Š” ๊ณ ์ • ๊ธˆ์•ก ํ• ์ธ์„ ์ ์šฉํ•ด๋‹ฌ๋ผ. (๋‚˜์ค‘์— ๋ณ€๊ฒฝ ๋  ์ˆ˜ ์žˆ๋‹ค.) ํ• ์ธ ์ •์ฑ…์€ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ์„ฑ์ด ๋†’๋‹ค. ํšŒ์‚ฌ์˜ ๊ธฐ๋ณธ ํ• ์ธ ์ •์ฑ…์„ ์•„์ง ์ •ํ•˜์ง€ ๋ชปํ–ˆ๊ณ , ์˜คํ”ˆ ์ง์ „๊นŒ์ง€ ๊ณ ๋ฏผ์„ ๋ฏธ๋ฃจ๊ณ  ์‹ถ๋‹ค. ์ตœ์•…์˜ ๊ฒฝ์šฐ ํ• ์ธ์„ ์ ์šฉํ•˜์ง€ ์•Š์„ ์ˆ˜ ๋„ ์žˆ๋‹ค. (๋ฏธํ™•์ •) ์ฃผ๋ฌธ ๋„๋ฉ”์ธ ํ˜‘๋ ฅ, ์—ญํ• , ์ฑ…์ž„ 1. ์ฃผ๋ฌธ ์ƒ์„ฑ: ํด๋ผ์ด์–ธํŠธ๋Š” ์ฃผ๋ฌธ ์„œ๋น„์Šค์— ์ฃผ๋ฌธ ์ƒ์„ฑ์„ ์š”์ฒญํ•œ๋‹ค. 2. ํšŒ์› ์กฐํšŒ: ํ• ์ธ์„ ์œ„ํ•ด์„œ๋Š” ํšŒ์› ๋“ฑ๊ธ‰์ด ํ•„์š”ํ•˜๋‹ค. ๊ทธ๋ž˜์„œ ์ฃผ๋ฌธ ์„œ๋น„์Šค๋Š” ํšŒ์› ์ €์žฅ์†Œ์—์„œ ํšŒ์›์„ ์กฐํšŒํ•œ๋‹ค. 3. ํ• ์ธ ์ ์šฉ: ์ฃผ๋ฌธ ์„œ๋น„์Šค๋Š” ํšŒ์› ๋“ฑ๊ธ‰์— ๋”ฐ๋ฅธ ํ• ์ธ ์—ฌ๋ถ€๋ฅผ ํ• ์ธ ์ •์ฑ…์— ์œ„์ž„ํ•œ๋‹ค. 4...

Spring/Spring ๊ธฐ๋ณธ

[์Šคํ”„๋ง ํ•ต์‹ฌ ์›๋ฆฌ - ๊ธฐ๋ณธํŽธ] - 5. ํšŒ์› ๋„๋ฉ”์ธ ์‹คํ–‰๊ณผ ํ…Œ์ŠคํŠธ

ํšŒ์› ๋„๋ฉ”์ธ ์‹คํ–‰๊ณผ ํ…Œ์ŠคํŠธ ํšŒ์› ๋„๋ฉ”์ธ - ํšŒ์› ๊ฐ€์ž… main ๋”๋ณด๊ธฐ package hello2.demo; import hello2.demo.member.Grade; import hello2.demo.member.Member; import hello2.demo.member.MemberService; import hello2.demo.member.MemberServiceImpl; public class MemberApp { public static void main(String[] args) { MemberService memberService = new MemberServiceImpl(); Member member = new Member(1L, "memberA", Grade.VIP); memberServ..

Spring/Spring ๊ธฐ๋ณธ

[์Šคํ”„๋ง ํ•ต์‹ฌ ์›๋ฆฌ - ๊ธฐ๋ณธํŽธ] - 4. ํšŒ์› ๋„๋ฉ”์ธ ๊ฐœ๋ฐœ

ํšŒ์› ๋„๋ฉ”์ธ ๊ฐœ๋ฐœ ํšŒ์› ๋“ฑ๊ธ‰ (Grade.class) ๋”๋ณด๊ธฐ package hello2.demo.member; public enum Grade { BASIC, VIP } ํšŒ์› ์—”ํ‹ฐํ‹ฐ, ๋ฉค๋ฒ„ (Member) ๋”๋ณด๊ธฐ id, ์ด๋ฆ„, ๋“ฑ๊ธ‰ package hello2.demo.member; public class Member { private Long id; private String name; private Grade grade; public Member(Long id, String name, Grade grade) { this.id = id; this.name = name; this.grade = grade; } public Long getId() { return id; } public void setId(L..

Spring/Spring ๊ธฐ๋ณธ

[์Šคํ”„๋ง ํ•ต์‹ฌ ์›๋ฆฌ - ๊ธฐ๋ณธํŽธ] - 3. ํšŒ์› ๋„๋ฉ”์ธ ์„ค๊ณ„

์„น์…˜ 2. ์Šคํ”„๋ง ํ•ต์‹ฌ ์›๋ฆฌ ์ดํ•ด 1 - ์˜ˆ์ œ ๋งŒ๋“ค๊ธฐ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ https://endyd1567.tistory.com/98 ์Šคํ”„๋ง ์ž…๋ฌธ - (1) ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ start.spring.io ์ดˆ๊ธฐ ์„ค์ • ์–ด๋–ค ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋‹น๊ฒจ์„œ ์“ธ ๊ฒƒ์ธ๊ฐ€ Spring Web : ์›น ํ”„๋กœ์ ํŠธ Thymeleaf : HTML์„ ๋งŒ๋“ค์–ด์ฃผ๋Š” ํƒฌํ”Œ๋ฆฟ ์—”์ง„ ์„ค์น˜ ํ›„ buuld.gradle ํŒŒ์ผ Open main / test ๋‚˜๋ˆ ์ ธ ์žˆ์Œ resources : xml ,html , ์„ค endyd1567.tistory.com ๋น„์ฆˆ๋‹ˆ์Šค ์š”๊ตฌ์‚ฌํ•ญ๊ณผ ์„ค๊ณ„ ํšŒ์› ํšŒ์›์„ ๊ฐ€์ž…ํ•˜๊ณ  ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค. ํšŒ์›์€ ์ผ๋ฐ˜๊ณผ VIP ๋‘ ๊ฐ€์ง€ ๋“ฑ๊ธ‰์ด ์žˆ๋‹ค. ํšŒ์› ๋ฐ์ดํ„ฐ๋Š” ์ž์ฒด DB๋ฅผ ๊ตฌ์ถ•ํ•  ์ˆ˜ ์žˆ๊ณ , ์™ธ๋ถ€ ์‹œ์Šคํ…œ๊ณผ ์—ฐ๋™ํ•  ์ˆ˜ ์žˆ๋‹ค. (๋ฏธํ™•์ •) ์ฃผ๋ฌธ๊ณผ ํ• ์ธ ์ •์ฑ… ..

hello_u
๐Ÿ˜œ