java.lang.NullPointerException: null
at java.lang.String.startsWith(String.java:1405) ~[na:1.8.0_171]
at java.lang.String.startsWith(String.java:1434) ~[na:1.8.0_171]
at springfox.documentation.builders.RequestHandlerSelectors$4.apply(RequestHandlerSelectors.java:98) ~[springfox-core-2.9.2.jar:null]
at springfox.documentation.builders.RequestHandlerSelectors$4.apply(RequestHandlerSelectors.java:95) ~[springfox-core-2.9.2.jar:null]
at com.google.common.base.Present.transform(Present.java:75) ~[guava-29.0-android.jar:na]
at springfox.documentation.builders.RequestHandlerSelectors$5.apply(RequestHandlerSelectors.java:114) ~[springfox-core-2.9.2.jar:null]
at springfox.documentation.builders.RequestHandlerSelectors$5.apply(RequestHandlerSelectors.java:111) ~[springfox-core-2.9.2.jar:null]
at com.google.common.base.Predicates$AndPredicate.apply(Predicates.java:353) ~[guava-29.0-android.jar:na]
at com.google.common.base.Predicates$AndPredicate.apply(Predicates.java:353) ~[guava-29.0-android.jar:na]
at com.google.common.collect.Iterators$5.computeNext(Iterators.java:637) ~[guava-29.0-android.jar:na]
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141) ~[guava-29.0-android.jar:na]
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136) ~[guava-29.0-android.jar:na]
at springfox.documentation.spring.web.scanners.ApiListingReferenceScanner.scan(ApiListingReferenceScanner.java:48) ~[springfox-spring-web-2.9.2.jar:null]
at springfox.documentation.spring.web.scanners.ApiDocumentationScanner.scan(ApiDocumentationScanner.java:67) ~[springfox-spring-web-2.9.2.jar:null]
at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.scanDocumentation(DocumentationPluginsBootstrapper.java:101) [springfox-spring-web-2.9.2.jar:null]
at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:167) [springfox-spring-web-2.9.2.jar:null]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) [spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) [spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) [spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) [spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) [spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:894) [spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) [spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at com.coinexchange.CoinCommonApplication.main(CoinCommonApplication.java:11) [classes/:na]
java.lang.NullPointerException: null
- 分析
1、啥都没干,为啥给我报了个空指针
2、是不是漏了啥,导致自动加载失败
3、是不是版本的问题,换个swagger2版本,好吧,帮你试过了,没用
两个小时过去了。。。解决了
- 问题点
@Data
@ConfigurationProperties(prefix = "swagger2") // properties配置获取,swagger2为配置前缀
public class SwaggerProperties {
/**
* 包扫描的路径
*/
public String basePackage ;
/**
* 联系人的名称
*/
public String name ;
/**
* 联系人的主页
*/
public String url ;
/**
* 联系人的邮箱
*/
public String email ;
/**
* API的标题
*/
public String title ;
/**
* API的描述
*/
public String description ;
/**
* API的版本号
*/
public String version ;
/**
* API的服务团队
*/
public String termsOfServiceUrl ;
}
- 解决
application.yaml
swagger2:
base-package: com.xxx.controller
name: xiaoming
url: https://gitee.com
title: xxx
description:xxx
version: 2.0
- 结语
1、@EnableConfigurationProperties的使用,了解后使用
2、这玩意,一个@Value的事,非装那b干啥