從春天啓動官方文檔(這是創建自定義開機春季變量的概念的一個亮點)波紋管,你會發現一個鏈接,介紹瞭解決方案Q/A。
Spring Boot jar附帶元數據文件,提供所有支持的配置屬性的詳細信息 。這些文件設計爲 允許IDE開發人員提供上下文幫助和「代碼完成」,因爲 用戶正在使用application.properties或application.yml 文件。
大部分元數據文件是在 編譯時自動生成的,處理所有註釋爲 @ConfigurationProperties的項目。但是,可以手動編寫部分 元數據用於角落案例或更高級用例。
配置的元數據文件被下 META-INF /彈簧配置-metadata.json位於內側罐他們使用一個簡單的JSON格式 與下任一「基團」或「屬性」 和其他值暗示分類的項目下的 「提示」 分類:
這裏是一個元數據的配置文件的一個示例:
{"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": "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和server.servlet-path可能在application.properties中指定爲 ,如下所示:
server.port = 9090 server。servlet-path =/home這些「groups」的級別高於 ,它們本身並不指定值,而是爲屬性提供 上下文分組。例如,server.port和 server.servlet-path屬性是服務器組的一部分。
注:
- 基團部是音符所需
- 「提示」是用於幫助用戶配置一個給定的屬性的其他信息。在配置spring.jpa.hibernate.ddl-auto屬性時,工具可以使用它爲none,validate,update,create和create-drop值提供一些自動完成幫助。
您可以輕鬆地生成使用 彈簧引導配置處理器罐子@ConfigurationProperties註釋 項目自己的配置元數據文件
您可以檢查這Q/A
**更多詳細信息檢查春季啓動附錄部分**