[Spring Boot] ApplicationRunner ๋ฑ๋ก ๋ฐฉ๋ฒ ์ ๋ฆฌ [Spring Boot] ApplicationRunner ๋ฑ๋ก ๋ฐฉ๋ฒ ์ ๋ฆฌ 1. ๋ณ๋์ ํด๋์ค์ @Component ๋ถ์ฌ์ ๋ฑ๋กํ๊ธฐ import org.springframework.boot.ApplicationArguments; import org.springframework.stereotype.Component; @Component public class ApplicationRunner implements org.springframework.boot.ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { // ์ฝ๋ ์์ฑ } } 2. @Configuration ํด๋์ค์ @Bean์ผ๋ก ์ง์ ๋ฑ๋กํ๊ธฐ .. 2020. 3. 26. [Spring] Component Scan๊ณผ Function์ ์ฌ์ฉํ ๋น ๋ฑ๋ก ๋ฐฉ๋ฒ [Spring] Component Scan๊ณผ Function์ ์ฌ์ฉํ ๋น ๋ฑ๋ก ๋ฐฉ๋ฒ 1. @ComponentScan @ComponentScan ์ ๋ ธํ ์ด์ ์ spring 3.1๋ถํฐ ๋์ ๋์ผ๋ฉฐ ์ค์ ๋ ์์ ์ง์ ๋ถํฐ ์ปดํฌ๋ํธ ํด๋์ค๋ฅผ scanningํ์ฌ ๋น์ผ๋ก ๋ฑ๋กํด์ฃผ๋ ์ญํ ์ ํ๋ค. ์ปดํฌ๋ํธ ํด๋์ค๋ ๋ค์ ์ ๋ ธํ ์ด์ ์ด ๋ถ์ ํด๋์ค๋ฅผ ์๋ฏธํ๋ค. @Component @Repository @Service @Controller @Configuration @ComponentScan์ ๊ฐ์ฅ ์ค์ํ ๋ ๊ฐ์ง ์์ฑ์ component๋ฅผ scanํ ์์ ์ง์ ์ ์ค์ ํ๋ ์์ฑ๊ณผ scanํ component ์ค ๋น์ผ๋ก ๋ฑ๋กํ์ง ์์ ํด๋์ค๋ฅผ ์ ์ธํ๋ ํํฐ ์์ฑ์ด๋ค. 1) Scan ์์ ์ง์ ์ค์ - basePackages()์.. 2020. 3. 2. [JAVA] ๋๋ค์(Lambda Expression) ๋๋ค์(Lambda Expression) JDK1.8๋ถํฐ ์ถ๊ฐ๋จ ๋๋ค์์ ๋์ → ์๋ฐ = ๊ฐ์ฒด์งํฅ ์ธ์ด + ํจ์ํ ์ธ์ด โป ๊ฐ์ฒด์งํฅ ์ธ์ด์ ํจ์ํ ์ธ์ด๋? ๊ฐ๊ฐ ๊ฐ์ฒด์งํฅ ํ๋ก๊ทธ๋๋ฐ ํจ๋ฌ๋ค์์ ์ง์ํ๋ ์ธ์ด์ ํจ์ํ ํ๋ก๊ทธ๋๋ฐ ํจ๋ฌ๋ค์์ ์ง์ํ๋ ์ธ์ด ๊ฐ์ฒด์งํฅ ํจ๋ฌ๋ค์ ๊ฐ์ ๋ฐ์ดํฐ์ ๋ํด ๋ค๋ฅธ ์ฒ๋ฆฌ ์ ์ฐจ(๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌํ๋ ๋ฐฉ์)๋ฅผ ์ฌ๋ฌ ๊ฐ ๋ช ์ํด์ผ ํ๋ ๊ฒฝ์ฐ๊ฐ ์์ฃผ ๋ฐ์ํ๋๋ฐ, ์ด ๋ ๊ณตํต๋ ๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌํ๋ ์ ์ฐจ๋ฅผ ํ๋๋ก ๋ฌถ์ด ๋ฐ์ดํฐ์ ์ฌ๋ฌ ์ ์ฐจ๋ฅผ ํ๋์ ๋จ์๋ก ๋ค๋ฃจ๋ ํจ๋ฌ๋ค์์ด๋ค. ํจ์ํ ํจ๋ฌ๋ค์ ์ฃผ์ด์ง ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ผ๋ก ๊ฐ์ฃผํ๊ณ ์๋ก์ด ๊ฐ์ ์์ฑํ๋ ํจ์์ ์ด์ ์ ๋ง์ถค์ผ๋ก์จ ๋ฉ๋ชจ๋ฆฌ ๊ด๋ฆฌ์ ๋ํ ๋ถ๋ด์ ์ ๊ฑฐํ๋ค. 1. ๋๋ค์์ด๋? ๋ฉ์๋๋ฅผ ํ๋์ ๊ฐ๊ฒฐํ ์(expression)์ผ๋ก ํํํ ๊ฒ ๋ฉ์๋๋ฅผ .. 2020. 1. 23. ์ด์ 1 ๋ค์