๐๏ธ ๋ฉด์ ์ ์ํ ์คํ๋ง ๋ถํธ ์ด๋ ธํ ์ด์ (1)
์คํ๋ง ๋ถํธ๋ ์ ํ๋ฆฌ์ผ์ด์ ๋ด์ ๋ค์ํ ์์๋ฅผ ๊ตฌ์ฑํ๊ณ ์ปค์คํ ํ๋๋ฐ ์ค์ํ ์ญํ ์ ํ๋ ์ด๋ ธํ ์ด์ ์ ์ ๊ณตํฉ๋๋ค. ์ด ํฌ์คํ ์์๋ ์ผ๋ฐ์ ์ด๊ณ ์ค์ํ ์ด๋ ธํ ์ด์ ์ ์ดํด๋ด์ผ๋ก์จ ๋ฉด์ ์ค๋น๋ฅผ ๋์ฑ ํจ๊ณผ์ ์ผ๋ก ํ ์ ์๊ฒ ํด์ค ๊ฒ์ ๋๋ค. ๋ฉด์ ์ ์ํ ์คํ๋ง ๋ถํธ ์ด๋ ธํ ์ด์ (2) - [https://careerly.co.kr/comments/96343] Core Annotations * @SpringBootApplication @Configraution, @EnableAutoConfiguration, @ComponentScan๊ณผ ๊ฐ์ ์ฃผ์ ์ด๋ ธํ ์ด์ ์ ๊ฒฐํฉํฉ๋๋ค. * @Configuration ์ด ์ด๋ ธํ ์ด์ ์ ์ฌ์ฉํ์ฌ ํด๋์ค์ ์คํ๋ง ๋น ๋ฐ ๊ตฌ์ฑ ๋ก์ง์ด ํฌํจ๋์ด ์์์ ๋ํ๋ ๋๋ค. * @Component Scan ์ด ์ด๋ ธํ ์ด์ ์ ์ปจํธ๋กค๋ฌ, ์๋น์ค ๋ฐ ๋ ํ์งํ ๋ฆฌ์ ๊ฐ์ ์คํ๋ง ๊ตฌ์ฑ ์์์ ๋ํด ๊ฒ์ํ ํจํค์ง๋ฅผ ์ง์ ํฉ๋๋ค. * @EnableAutoConfiguration application.properties ๋๋ application.yml ํ์ผ์ ์์ฑ์ ๊ธฐ๋ฐ์ผ๋ก ์คํ๋ง ๋ถํธ ํ๋ก๊ทธ๋จ์ ์๋ ๊ตฌ์ฑ์ ํ์ฑํํฉ๋๋ค. Controller Annotations * @RestController ํด๋น ํด๋์ค๊ฐ HTTP ์์ฒญ์ ์ฒ๋ฆฌํ๊ณ JSON, XML๋ฑ๊ณผ ๊ฐ์ ๋ค์ํ ํ์์ผ๋ก ์๋ต์ ๋ฐํํ๋ ์ปจํธ๋กค๋ฌ๋ผ๊ณ ํ์ํฉ๋๋ค. * @Controller @RestController์ ์ ์ฌํ์ง๋ง, ์๋ต์ ๋ทฐ ํ์์ผ๋ก ๋ฐํํ๋ค๊ณ ํ์ํฉ๋๋ค. Service and Repository Annotations * @Service ํด๋น ํด๋์ค๊ฐ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋น์ฆ๋์ค ๋ก์ง์ ์ ๊ณตํ๋ ์๋น์ค๋ผ๊ณ ๋ช ์ํฉ๋๋ค. * @Repository ํด๋น ํด๋์ค๊ฐ ์์ฉ ํ๋ก๊ทธ๋จ์ ๋ํ ๋ฐ์ดํฐ ์ ๊ทผ์ ์ ๊ณตํ๋ ๋ ํ์งํ ๋ฆฌ๋ผ๊ณ ํ์ํฉ๋๋ค. Dependency Injection Annotations * @Autowired ์์ฑ์, ํ๋, setter ๋ฉ์๋์ ๊ด๊ณ ์์ด ์์กด์ฑ์ ํด๋์ค์ ์ฃผ์ ํฉ๋๋ค. Request Mapping Annotations * @RequestMapping ์ปจํธ๋กค๋ฌ์ ํน์ ๋ฉ์๋๋ฅผ ์ ๊ณต๋ ์๋ํฌ์ธํธ์ ๋งคํํ์ฌ ๋ค์ํ HTTP ๋ฉ์๋(GET, POST, PUT, DELETE ๋ฑ)๋ฅผ ์ง์ํฉ๋๋ค. @GetMapping๊ณผ @PostMapping์ ๊ธฐ๋ฐ์ ๋๋ค.