-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Closed
Labels
status: duplicateA duplicate of another issueA duplicate of another issue
Description
Hi,
i am using spring boot 1.5.2.RELEASE and mongodb. i wrote some tests with annotation @DatamongoTest and was everything fine. it set up embedded mongo db and autowired my repository classes. But after I add swagger to my project my test fails with the below error:
"Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'documentationPluginsBootstrapper' defined in URL [jar:file:/C:/Users/barbakini/.m2/repository/io/springfox/springfox-spring-web/2.6.1/springfox-spring-web-2.6.1.jar!/springfox/documentation/spring/web/plugins/DocumentationPluginsBootstrapper.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcRequestHandlerProvider' defined in URL [jar:file:/C:/Users/barbakini/.m2/repository/io/springfox/springfox-spring-web/2.6.1/springfox-spring-web-2.6.1.jar!/springfox/documentation/spring/web/plugins/WebMvcRequestHandlerProvider.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.util.List<org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}"
I tricked it with adding two mockbean to my test class but i believe this shouldn't be necessary. You can find additional info below:
Application class:
@SpringBootApplication
@EnableSwagger2
public class ParameterApplication {.....}
Test Class:
@RunWith(SpringRunner.class)
@DataMongoTest
public class ParameterRepositoryTest {
@MockBean
private RequestMappingInfoHandlerMapping RequestMappingInfoHandlerMapping;
@MockBean
private ServletContext ServletContext;
@Autowired
private ParameterRepository parameterRepository;
}
ParameterRepository:
@Repository
public interface ParameterRepository extends MongoRepository<Parameter, String>, MongoTemplateRepository {
}
Metadata
Metadata
Assignees
Labels
status: duplicateA duplicate of another issueA duplicate of another issue