ํ™ˆ Spring annotation
ํฌ์ŠคํŠธ
์ทจ์†Œ

Spring annotation

๐Ÿ’ป @ComponentScan

@Component ์‹œ๋ฆฌ์ฆˆ ์–ด๋…ธํ…Œ์ด์…˜ (@Controller, @RestController, @Service, @Repository, @Configuration ๋“ฑ)์ด ๋ถ™์€ ํด๋ž˜์Šค๋ฅผ ๋ฐœ๊ฒฌํ•ด ๋นˆ(bean)์— ๋“ฑ๋กํ•˜๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’ป @Component

์ž‘์„ฑํ•œ class๋ฅผ bean์œผ๋กœ ๋“ฑ๋กํ•˜๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’ป @Controller

Spring์—์„œ Controller๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค

๐Ÿ’ป @RestController

@Controller์™€ ๋‹ค๋ฅด๊ฒŒ view๊ฐ€ ์—†๋Š” Controller๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’ป @Service

Spring์—์„œ Service๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’ป @Repository

Spring์—์„œ Repository๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’ป @RequestMapping

์š”์ฒญ URL์— ๋Œ€ํ•œ๊ฒƒ์„ ์–ด๋–ค ๋ฉ”์†Œ๋“œ๊ฐ€ ์ฒ˜๋ฆฌํ• ์ง€ ๋งตํ•‘ํ•ด์ฃผ๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’ป @PathVariable

URL์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๋ฐ›์•„์˜ค๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’ป @RequestParam

์š”์ฒญ URL์˜ query parameter์—์„œ ๊ฐ€์ ธ์™€ ๋งคํ•‘ํ•ด์ฃผ๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.

์ด ๊ธฐ์‚ฌ๋Š” ์ €์ž‘๊ถŒ์ž์˜ CC BY 4.0 ๋ผ์ด์„ผ์Šค๋ฅผ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค.

HTTP ๋ฉ”์„œ๋“œ

REST API