在Springboot RestApi中添加Swagger实现后获取BeanCreationException

时间:2017-11-09 09:00:11

标签: rest spring-boot jax-rs swagger-ui swagger-2.0

下面我添加了添加Swagger2feature之后的代码

BeanCreationException , BeanInstantiationException and NoSuchMethodError(io.swagger.jaxrs.config.BeanConfig.setUsePathBasedConfig(Z)V)

主类:

public static void main(String[] args) {
    SpringApplication.run(TechpubsServicesSBApp.class, args);
} 

@Bean
public Server rsServer() {
    JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
    endpoint.setBus(bus);
    endpoint.setServiceBeans(Arrays.<Object>asList(testImpl));
    endpoint.setAddress("/");
    endpoint.setProviders(Arrays.<Object>asList(testExceptionMapper));
    endpoint.setProvider(new JacksonJsonProvider());
    Swagger2Feature swagger2Feature = new Swagger2Feature();
    swagger2Feature.setTitle("Test API");
    swagger2Feature.setVersion(deployedVersion.concat("(").concat(deployedInstance.toUpperCase()).concat(")"));
    swagger2Feature.setPrettyPrint(true);
    swagger2Feature.setSupportSwaggerUi(true);       
    endpoint.setFeatures(Collections.singletonList(swagger2Feature));
    return endpoint.create();
    }</i>

错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rsServer' defined in com.geaviation.techpubs.ws.TechpubsServicesSBApp: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.cxf.endpoint.Server]: Factory method 'rsServer' threw exception; nested exception is java.lang.NoSuchMethodError: io.swagger.jaxrs.config.BeanConfig.setUsePathBasedConfig(Z)V

有没有人遇到类似的错误?

0 个答案:

没有答案