Back End/Spring Boot
[Spring] JUnit - unsatisfied dependency mockmvc 에러
DevPing9_
2021. 11. 30. 19:05
# 에러 사항
- MockMvc Bean 을 주입 받지 못함
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.bookmarkmanager.bookmarkmanager.main.login.LoginApiTest': Unsatisfied dependency expressed through field 'mockMvc'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.test.web.servlet.MockMvc' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
# 해결 방법
- @AutoConfigureMockMvc 어노테이션을 @SpringBootTest 위치에 같이 달아둠
728x90