question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@DataMongoTest tries to setup swagger when @EnableSwagger2 exist on application

See original GitHub issue

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  {
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
barbakinicommented, May 30, 2017

No, I didn’t face that. You should ask in stackoverflow or some other sites. Definitely it is not about any spring related bug so we should not write here.

0reactions
sshamsuncommented, May 30, 2017

@barbakini Thanks for all the inputs, I will reach out on stack overflow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Swagger 2 Issue - Spring Boot - Stack Overflow
Just add this configuration to your application.properties spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER.
Read more >
Setting Up Swagger 2 with a Spring REST API - Baeldung
In plain Spring projects, we need to enable Swagger 2 explicitly. To do so, we have to use the @EnableSwagger2WebMvc on our configuration...
Read more >
Spring Boot - Enabling Swagger2 - Tutorialspoint
The @EnableSwagger2 annotation is used to enable the Swagger2 for your Spring Boot application. The code for main Spring Boot application is shown...
Read more >
Springfox Reference Documentation - GitHub Pages
@Configuration @EnableWebMvc //NOTE: Only needed in a non-springboot application @EnableSwagger2 @ComponentScan("com.myapp.controllers") public ...
Read more >
Swagger Annotation and Spring Configuration - Xoriant
To Use plugin, we should create Java configuration class with @Configuration class and define this class in application context file. @EnableSwagger2 public ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found