设为首页 加入收藏

TOP

SpringBoot系列三:SpringBoot自定义Starter(三)
2018-11-21 22:08:37 】 浏览:586
Tags:SpringBoot 系列 定义 Starter
对象可以包含下表中描述的属性:

每个 “hints” 元素的 providers 属性中的 JSON 对象可以包含下表中描述的属性:

3.4 配置元数据

所以如果想有更好的用户体验,可以为我们自定义的 starter 配置元数据,下面就为 HelloWorld 配置元数据。

在 META-INF 下创建 spring-configuration-metadata.json 文件:

在文件中输入如下内容:

{
  "hints":[{
    "name":"hello.msg",
    "values":[{
      "value":"你好",
      "description":"中文方式打招呼"
    },{
      "value":"Hi",
      "description":"英文方式打招呼"
    }]
  }],
  "groups":[
    {
      "sourceType": "com.seagetech.spring.boot.helloworld.HelloWorldProperties",
      "name": "hello",
      "type": "com.seagetech.spring.boot.helloworld.HelloWorldProperties"
    }],
  "properties":[
    {
      "sourceType": "com.seagetech.spring.boot.helloworld.HelloWorldProperties",
      "name": "hello.msg",
      "type": "java.lang.String",
      "description": "打招呼的内容",
      "defaultValue": "Worlds"
    }]
}

然后将 autoconfigure 模块重新打包,接下来就是在 spring-boot-demo 项目中使用,如下图所示,就有了属性的提示:

首页 上一页 1 2 3 4 下一页 尾页 3/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇让SpringBoot启动更快一点 下一篇SpringBoot系列二:SpringBoot自..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目