| 
							Spring Boot jar 包含元数据文件,它们提供所有支持的配置属性的详细信息。这些文件被设计成让 IDE 开发人员在用户处理  
							大多数元数据文件是在编译时通过处理  
								配置元数据文件位于  {"groups": [
	{
		"name": "server",
		"type": "org.springframework.boot.autoconfigure.web.ServerProperties",
		"sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties"
	},
	{
		"name": "spring.jpa.hibernate",
		"type": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate",
		"sourceType": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties",
		"sourceMethod": "getHibernate()"
	}
	...
],"properties": [
	{
		"name": "server.port",
		"type": "java.lang.Integer",
		"sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties"
	},
	{
		"name": "server.address",
		"type": "java.net.InetAddress",
		"sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties"
	},
	{
		  "name": "spring.jpa.hibernate.ddl-auto",
		  "type": "java.lang.String",
		  "description": "DDL mode. This is actually a shortcut for the \"hibernate.hbm2ddl.auto\" property.",
		  "sourceType": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate"
	}
	...
],"hints": [
	{
		"name": "spring.jpa.hibernate.ddl-auto",
		"values": [
			{
				"value": "none",
				"description": "Disable DDL handling."
			},
			{
				"value": "validate",
				"description": "Validate the schema, make no changes to the database."
			},
			{
				"value": "update",
				"description": "Update the schema if necessary."
			},
			{
				"value": "create",
				"description": "Create the schema and destroy previous data."
			},
			{
				"value": "create-drop",
				"description": "Create and then destroy the schema at the end of the session."
			}
		]
	}
]}
								每个属性是用户用给定值指定的配置项。例如,可以在  server.port=9090 server.address=127.0.0.1 
								“groups” 是较高级别的项,它们本身不指定值,而是为属性提供上下文分组。例如, 
 
								最后,“hints” 是用来帮助用户配置给定属性的附加信息。例如,当开发人员配置  
									 
 
									 
 每个属性元素的弃权属性中包含的 JSON 对象可以包含以下属性: 
 
 
									还可以通过将  @ConfigurationProperties("app.acme") public class AcmeProperties { private String name; public String getName() { ... } public void setName(String name) { ... } @DeprecatedConfigurationProperty(replacement = "app.acme.name") @Deprecated public String getTarget() { return getName(); } @Deprecated public void setTarget(String target) { setName(target); } } 
 
									前面的代码确保已弃权的属性仍然有效(委派到后台的名称属性)。一旦可以从公共 API 中删除  
									 
 
									每个提示元素的  
 
									每个提示元素的  
 为了改善用户体验并进一步帮助用户配置给定属性,可以提供附加元数据: 
 
									每个提示的  
									如果你的属性属于  
									假设一个  @ConfigurationProperties("sample") public class SampleProperties { private Map<String,Integer> contexts; // getters and setters } 
									magic 是(在这个例子中)是  {"hints": [
	{
		"name": "sample.contexts.keys",
		"values": [
			{
				"value": "sample1"
			},
			{
				"value": "sample2"
			}
		]
	}
]}
 提供者是将语义附加到属性的强大方法。在本节中,我们定义了你可以使用自己的提示的官方提供者。但是,你最喜欢的 IDE 可以实现其中的一些或全部。而且,它最终可以提供它自己的。 
 下表总结了支持提供者的列表: 
 
 特殊的 any 提供者值允许提供任何附加值。如果支持,则应使用基于属性类型的正则值验证。 如果你有一个值列表,并且任何额外的值仍然应该被认为是有效的,则通常使用此提供者。 
										下面的示例为  {"hints": [
	{
		"name": "system.state",
		"values": [
			{
				"value": "on"
			},
			{
				"value": "off"
			}
		],
		"providers": [
			{
				"name": "any"
			}
		]
	}
]}注意,在前面的示例中,也允许任何其他值。 class-reference 提供者自动完成项目中可用的类。此提供者支持以下参数: 
 
										以下元数据片段对应于定义要使用的  {"hints": [
	{
		"name": "server.servlet.jsp.class-name",
		"providers": [
			{
				"name": "class-reference",
				"parameters": {
					"target": "javax.servlet.http.HttpServlet"
				}
			}
		]
	}
]}
										handle-as 作为提供者,你可以将属性的类型替换为更高级的类型。这通常发生在属性具有  
 可以使用以下类型: 
 
 
										下面的元数据片段对应于标准  {"hints": [
	{
		"name": "spring.liquibase.change-log",
		"providers": [
			{
				"name": "handle-as",
				"parameters": {
					"target": "org.springframework.core.io.Resource"
				}
			}
		]
	}
]}logger-name 提供这自动完成有效记录器名称。通常,当前项目中可用的包和类名可以自动完成。特定的框架可以有额外的魔术记录器名称,也可以支持。 由于日志记录器名称可以是任意名称,因此此提供者应该允许任何值,但是可以突出显示项目的类路径中不可用的有效包和类名称。 
										下面的元数据片段对应于标准  {"hints": [
	{
		"name": "logging.level.keys",
		"values": [
			{
				"value": "root",
				"description": "Root logger used to assign the default logging level."
			}
		],
		"providers": [
			{
				"name": "logger-name"
			}
		]
	},
	{
		"name": "logging.level.values",
		"values": [
			{
				"value": "trace"
			},
			{
				"value": "debug"
			},
			{
				"value": "info"
			},
			{
				"value": "warn"
			},
			{
				"value": "error"
			},
			{
				"value": "fatal"
			},
			{
				"value": "off"
			}
		],
		"providers": [
			{
				"name": "any"
			}
		]
	}
]}spring-bean-reference 提供者自动完成当前项目配置中定义的 bean。此提供者支持以下参数: 
 
										以下元数据片段对应于定义要使用的  {"hints": [
	{
		"name": "spring.jmx.server",
		"providers": [
			{
				"name": "spring-bean-reference",
				"parameters": {
					"target": "javax.management.MBeanServer"
				}
			}
		]
	}
]}
 
								通过使用  在 Maven 中,依赖项应该声明为可选的,如下面的示例所示: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> 
								对于 Gradle 4.5 和更早版本,依赖关系应该在  dependencies {
	compileOnly "org.springframework.boot:spring-boot-configuration-processor"
}
								对于 Gradle 4.6 以及更高版本,依赖关系应该在  dependencies {
	annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
}
								如果你使用的是  compileJava.dependsOn(processResources) 这种依赖性确保在编译过程中注解处理器运行时附加元数据可用。 
								处理器选择用  
 
								属性是通过标准 getter 和 setter 的存在来发现的,它们具有对集合类型的特殊处理(即使只存在 getter 也会检测到)。注解处理器还支持使用  
 注解处理器自动将内部类视为嵌套属性。考虑下面的类: @ConfigurationProperties(prefix="server") public class ServerProperties { private String name; private Host host; // ... getter and setters public static class Host { private String ip; private int port; // ... getter and setters } } 
									前面的示例为  
 
									Spring Boot 的配置文件处理非常灵活,并且通常存在不绑定  如果引用已自动检测到的属性,则重写描述、默认值和弃用信息(如果指定)。如果当前模块中未标识手动属性声明,则将其添加为新属性。 
									附加的  |