打开swagger页面时报错: nested exception is java.lang.NoSuchMethodError: 'void com.fasterxml.jackson.core.util.BufferRecycler
我的swagger配置:
@Configuration
@EnableSwagger2
public class SwaggerConfig {
//配置了swagger的Docket的bean实例
@Bean
public Docket docket() {
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
Contact contact = new Contact("zyblogs", "http://localhost:8008", "1417243391@qq.com");
return new ApiInfo(
"swagger",
"文档",
"1.0",
"urn:tos",
contact,
"Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0",
new ArrayList()
);
}
}
检查配置,没什么问题。
后面发现原来问题是我的jar包当中的只引入了这个:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-core.version}</version>
</dependency>
之后又引入了以下的:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-core.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-core.version}</version>
</dependency>
再次启动,打卡swagger页面,成功了。