Errors
[Errors] org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
커밍이즈스프링
2022. 3. 24. 14:30
반응형
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
pom.xml
@Configuration
@EnableSwagger2
public class AppConfig{
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).consumes(getConsumeContentTypes()).produces(getProduceContentTypes())
.apiInfo(getApiInfo()).select()
.apis(RequestHandlerSelectors.basePackage("com.diquest.hanabank.controller"))
.paths(PathSelectors.ant("/**")).build();
}
private ApiInfo getApiInfo() {
return new ApiInfoBuilder().title("API").description("hana_bank").contact(new Contact("hana_bank_swaager", "diquest.com", "vividjty"))
.version("1.0").build();
}
private Set<String> getProduceContentTypes() {
Set<String> produces = new HashSet<>();
produces.add("application/json;charset=UTF-8");
return produces;
}
private Set<String> getConsumeContentTypes() {
Set<String> consumes = new HashSet<>();
consumes.add("application/json;charset=UTF-8");
consumes.add("application/x-www-form-urlencoded");
return consumes;
}
}
AppConfig.java
spring boot에서 swagger를 설정하고 난 뒤, 실행을 하니
아래와 같은 에러가 떳다.
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
그래서 application.propertis에
설정값을 추가 해줬고 다시 실행하니 정상적으로 swagger가 실행이 되었다.
spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER
반응형