我们发现在编写yml 或者Properties 配置文件的时候,写出前半部分会出现相关配置提示,如下:
- 引入以下依赖
2、编写配置信息// 这个我没有引入,使用spring boot自带的 org.springframework.boot spring-boot-configuration-processor true org.springframework.boot spring-boot-autoconfigure
package com.nn.config;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.List;
@ConfigurationProperties(prefix = "zuul")
@Getter
@Setter
public class MyProperties {
private String name;
private String sex;
private List ignorePath;
}
3、maven 编译打包
- maven install 将项目发布到本地maven仓库中,以供其他项目依赖使用
- 打包成功后在class目录下生成 “META-INF/spring-configuration-metadata.json” 文件
- spring-configuration-metadata.json
{
"groups": [
{
"name": "zuul",
"type": "com.nn.config.MyProperties",
"sourceType": "com.nn.config.MyProperties"
}
],
"properties": [
{
"name": "zuul.ignore-path",
"type": "java.util.List",
"sourceType": "com.nn.config.MyProperties"
},
{
"name": "zuul.name",
"type": "java.lang.String",
"sourceType": "com.nn.config.MyProperties"
},
{
"name": "zuul.sex",
"type": "java.lang.String",
"sourceType": "com.nn.config.MyProperties"
}
],
"hints": []
}
4、引入坐标
- 在yml 配置中添加我们前面自定义的配置,就会出现自动提示



