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

์ž๋ฐ”3

Spring - ๋นˆ ์ƒ๋ช…์ฃผ๊ธฐ ์ฝœ๋ฐฑ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ปค๋„ฅ์…˜ ํ’€์ด๋‚˜, ๋„คํŠธ์›Œํฌ ์†Œ์ผ“์ฒ˜๋Ÿผ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹œ์ž‘ ์‹œ์ ์— ํ•„์š”ํ•œ ์—ฐ๊ฒฐ์„ ๋ฏธ๋ฆฌ ํ•ด๋‘๊ณ , ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ข…๋ฃŒ ์‹œ์ ์— ์—ฐ๊ฒฐ์„ ๋ชจ๋‘ ์ข…๋ฃŒํ•˜๋Š” ์ž‘์—…์„ ์ง„ํ–‰ํ•˜๋ ค๋ฉด, ๊ฐ์ฒด์˜ ์ดˆ๊ธฐํ™”์™€ ์ข…๋ฃŒ ์ž‘์—…์ด ํ•„์š”ํ•˜๋‹ค. ์Šคํ”„๋ง ๋นˆ์€ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ผ์ดํ”„์‚ฌ์ดํด์„ ๊ฐ€์ง„๋‹ค. ๊ฐ์ฒด ์ƒ์„ฑ โžก๏ธ ์˜์กด๊ด€๊ณ„ ์ฃผ์ž… ์Šคํ”„๋ง ๋นˆ์€ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๊ณ , ์˜์กด๊ด€๊ณ„ ์ฃผ์ž…์ด ๋‹ค ๋๋‚œ ๋‹ค์Œ์—์•ผ ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์ค€๋น„๊ฐ€ ์™„๋ฃŒ๋œ๋‹ค. ๋”ฐ๋ผ์„œ ์ดˆ๊ธฐํ™” ์ž‘์—…์€ ์˜์กด๊ด€๊ณ„ ์ฃผ์ž…์ด ๋ชจ๋‘ ์™„๋ฃŒ๋˜๊ณ  ๋‚œ ๋‹ค์Œ์— ํ˜ธ์ถœํ•ด์•ผ ํ•œ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ๊ฐœ๋ฐœ์ž๊ฐ€ ์˜์กด๊ด€๊ณ„ ์ฃผ์ž…์ด ๋ชจ๋‘ ์™„๋ฃŒ๋œ ์‹œ์ ์„ ์–ด๋–ป๊ฒŒ ์•Œ ์ˆ˜ ์žˆ์„๊นŒ? ์Šคํ”„๋ง์€ ์˜์กด๊ด€๊ณ„ ์ฃผ์ž…์ด ์™„๋ฃŒ๋˜๋ฉด ์Šคํ”„๋ง ๋นˆ์—๊ฒŒ ์ฝœ๋ฐฑ ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด์„œ ์ดˆ๊ธฐํ™” ์‹œ์ ์„ ์•Œ๋ ค์ฃผ๋Š” ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•œ๋‹ค. ๋˜ํ•œ ์Šคํ”„๋ง์€ ์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ๊ฐ€ .. 2023. 7. 16.
Spring - ์Šคํ”„๋ง ๋นˆ ์กฐํšŒ -๊ธฐ๋ณธ ์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ์—์„œ ์Šคํ”„๋ง ๋นˆ์„ ์ฐพ๋Š” ๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ ์กฐํšŒ ๋ฐฉ๋ฒ• ac.getBean(๋นˆ์ด๋ฆ„, ํƒ€์ž…) ac.getBean(ํƒ€์ž…) ์กฐํšŒ ๋Œ€์ƒ ์Šคํ”„๋ง ๋นˆ์ด ์—†์œผ๋ฉด ์˜ˆ์™ธ ๋ฐœ์ƒ NoSuchBeanDefinitionException: No bean named 'xxxxx' available public class ApplicationContextBasicFindTest { AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(AppConfig.class); @Test @DisplayName("๋นˆ ์ด๋ฆ„์œผ๋กœ ์กฐํšŒ") void findBeanByName(){ MemberService memberService = ac.getBea.. 2023. 7. 9.
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.