官方提供的spring boot starter的配置项,咱们用IDE配置的时候通常都有自动提示的,以下图所示
而咱们本身自定义的配置却没有,对开发很是不友好容易打错配置,那这个是怎样实现的呢?html
IDE是经过读取配置信息的元数据而实现自动提示的,而元数据在目录META-INF
中的spring-configuration-metadata.json
或者 additional-spring-configuration-metadata.json
spring
以我这个本身开发的starter中的自定义配置文件为例,若是本身手动建立这些元数据的话工做量比较大,使用IDEA
的话有自动生成功能json
在zlt-swagger2-spring-boot-starter
工程中添加如下jar包segmentfault
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency>
搜索Annotation Processor
并设置Enable annotation processing
分布式
项目在从新编译后就会自动生成spring-configuration-metadata.json
文件spring-boot
自定义的swagger配置已经能自动提示了测试
参考资料
https://docs.spring.io/spring-boot/docs/current/reference/html/configuration-metadata.htmlspa
推荐阅读.net