Small Asteroid Blog

[Spring boot] modelMapper 에러 - required a bean of type 'org.modelmapper.ModelMapper' that could not be found. 본문

백엔드/Spring

[Spring boot] modelMapper 에러 - required a bean of type 'org.modelmapper.ModelMapper' that could not be found.

작은소행성☄️ 2022. 11. 22. 18:42
728x90

modelMapper 를 사용하려는데 다음과 같은 에러가 나왔다. 

 

 

에러 메시지

Parameter 1 of constructor in com.restapi.auth.service.impl.RelativeServiceImpl required a bean of type 'org.modelmapper.ModelMapper' that could not be found.

1개 이상의 자동주입 후보가 있어야 한다는 뜻으로 @Bean을 등록해준다. 

 

 

@Service
@RequiredArgsConstructor
public class MemberServiceImpl implements MemberService {
    private final ModelMapper modelMapper;
}

 

@Bean 등록

import org.modelmapper.ModelMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig {
    @Bean
    public ModelMapper modelMapper(){
        return new ModelMapper();
    }
}

 

 

 

728x90
반응형