Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

No qualifying bean of type 'springfox.documentation.schema.property.ModelPropertiesProvider' after obfuscation with proguard

Ask Question

My Swagger config works fine normally, but when I use proguard to obfuscate the code, I get the error

No qualifying bean of type 'springfox.documentation.schema.property.ModelPropertiesProvider'

If I comment @Configuration, the spring boot project starts but swagger documentation doesn't work and I get another error

Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where all the swagger resources are served

Here is my swagger config class

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
@Profile("swagger")
public class SwaggerConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
            .select()
            .apis(RequestHandlerSelectors.any())
            .paths(PathSelectors.any())
            .build()
            .apiInfo(apiInfo());
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
            .title("Spring REST TSU service with Swagger")
            .description("Spring REST TSU service with Swagger")
            .termsOfServiceUrl("...")
            .contact(new Contact("Test name", "", "test@asdf.com"))
            .version("1.0")
            .build();

Solved for me! Override the method buildDefaultBeanName in class AnnotationBeanNameGenerator. eg.

@ServletComponentScan
@SpringBootApplication
public class WebApplication {
public static void run() {
    new SpringApplicationBuilder(WebApplication.class)
            .beanNameGenerator(new ProGuardBeanNameGenerator()).run();
static class ProGuardBeanNameGenerator extends AnnotationBeanNameGenerator {
    @Override
    protected String buildDefaultBeanName(BeanDefinition definition) {
        return definition.getBeanClassName();
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.