Framework/Springboot

[Springboot] required a bean of type that could not be found error ์˜ค๋ฅ˜ ์›์ธ ๋ฐ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

yuri lee 2025. 2. 5. 22:34
๋ฐ˜์‘ํ˜•

Intro

์Šคํ”„๋ง์„ ์‚ฌ์šฉํ•˜๋˜ ๋„์ค‘ ๋‹ค์Œ์˜ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค. 

Parameter 0 of constructor in 

kr.co.example.api.service.example.impl.ExampleApiServiceImpl 

required a bean of type 'kr.co.example.common.client.aws.AwsS3Client' 

that could not be found.

 

Why

Spring์—์„œ ์œ„์™€ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ์ด์œ ๋Š” AwsS3Client ๋นˆ์„ ์ฐพ์„ ์ˆ˜ ์—†๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

 

How to Solve    

ํ•ด๋‹น ํ”„๋กœ์ ํŠธ์˜ ๊ฒฝ์šฐ ๊ฒฝ์šฐ AppConfig ํŒŒ์ผ์„ ํ†ตํ•ด์„œ ์Šคํ”„๋ง ๋นˆ์„ ๋“ฑ๋กํ•˜๊ณ , ์˜์กด์„ฑ ์ฃผ์ž…์„ ๊ด€๋ฆฌํ•˜๊ณ  ์žˆ์–ด์„œ AppConfig ํŒŒ์ผ์„ ์ˆ˜์ •ํ•ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค. 

@Configuration
class AppConfig(
) {
    @Bean
    fun awsS3Client(): AwsS3Client {
        return AwsS3ClientImpl()
    }
}

 

๋ฐ˜์‘ํ˜•