[Spring] ... required a bean of type ... ์˜ค๋ฅ˜

hiworldยท2022๋…„ 7์›” 5์ผ
0
post-thumbnail

[์ž‘์„ฑ ์ค‘]

๐Ÿ˜ต ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of constructor in com.example.service.BoardService required a bean of type 'com.example.repository.BoardRepository' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.example.repository.BoardRepository' in your configuration.

๐Ÿค” ์˜ค๋ฅ˜ ์›์ธ

  • ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋ฉด, BoardService์˜ ์ƒ์„ฑ์ž ์ฒซ ๋ฒˆ์งธ parameter์— ํ•„์š”ํ•œ BoardRepository bean์„ ์ฃผ์ž…๋ฐ›์•„์•ผ ํ•˜๋Š”๋ฐ BoardRepository๊ฐ€ bean์œผ๋กœ ๋“ฑ๋ก๋˜์–ด ์žˆ์ง€ ์•Š์•„ ๋ฐœ์ƒํ•˜๋Š” ์˜ค๋ฅ˜์ด๋‹ค.

  • ์Šคํ”„๋ง๋ถ€ํŠธ์˜ @ComponentScan ์–ด๋…ธํ…Œ์ด์…˜์€ ์ง€์ •๋œ ๋ฒ”์œ„ ์•ˆ์—์„œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ฐพ์•„ ์ž๋™์œผ๋กœ ๋นˆ์œผ๋กœ ๋“ฑ๋กํ•˜๊ณ  ๊ด€๋ฆฌํ•ด์ค€๋‹ค. ์ด๋•Œ ์ด ์ปดํฌ๋„ŒํŠธ์—๋Š” @Component, @Repository, @Service, @Controller, @Configuration

profile
๋ฐ”์˜๊ฒŒ ์‚ด์•„ ๋ณด์ž!

0๊ฐœ์˜ ๋Œ“๊ธ€