[Spring] ๋น์ Scope - ์ฑ๊ธํค๊ณผ ํ๋กํ ํ์ [Spring] ๋น์ Scope - ์ฑ๊ธํค๊ณผ ํ๋กํ ํ์ ๋น์ ๋ฑ๋กํ ๋ ์๋ฌด๋ฐ ์ค์ ์ ํ์ง ์์ผ๋ฉด ๊ธฐ๋ณธ์ ์ผ๋ก ๋น์ ์ฑ๊ธํค scope์ ๊ฐ๋๋ค. ์ฑ๊ธํค scope์ด๋ ์ดํ๋ฆฌ์ผ์ด์ ์ ๋ฐ์ ๊ฑธ์ณ ํด๋น ๋น์ ์ธ์คํด์ค๋ฅผ ์ค์ง ํ๋๋ง ์์ฑํด์ ์ฌ์ฉํ๋ ๊ฒ์ด๋ค. 1. Singleton Scope Single, Proto ํด๋์ค๋ฅผ ์๋ก ๋ง๋ค๊ณ @Component๋ฅผ ๋ถ์ฌ ๋น์ผ๋ก ๋ฑ๋กํ๋ค. Single.java 1 2 3 4 5 6 7 8 9 10 11 12 13 import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class Single { @.. 2020. 3. 3. ์ด์ 1 ๋ค์