附录B.1. 元数据格式

配置元数据位于jars文件中的META-INF/spring-configuration-metadata.json,它们使用一个具有”groups”或”properties”分类节点的简单JSON格式:

  1. {"groups": [
  2. {
  3. "name": "server",
  4. "type": "org.springframework.boot.autoconfigure.web.ServerProperties",
  5. "sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties"
  6. },
  7. {
  8. "name": "spring.jpa.hibernate",
  9. "type": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate",
  10. "sourceType": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties",
  11. "sourceMethod": "getHibernate()"
  12. }
  13. ...
  14. ],"properties": [
  15. {
  16. "name": "server.port",
  17. "type": "java.lang.Integer",
  18. "sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties"
  19. },
  20. {
  21. "name": "server.servlet-path",
  22. "type": "java.lang.String",
  23. "sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties",
  24. "defaultValue": "/"
  25. },
  26. {
  27. "name": "spring.jpa.hibernate.ddl-auto",
  28. "type": "java.lang.String",
  29. "description": "DDL mode. This is actually a shortcut for the \"hibernate.hbm2ddl.auto\" property.",
  30. "sourceType": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate"
  31. }
  32. ...
  33. ],"hints": [
  34. {
  35. "name": "spring.jpa.hibernate.ddl-auto",
  36. "values": [
  37. {
  38. "value": "none",
  39. "description": "Disable DDL handling."
  40. },
  41. {
  42. "value": "validate",
  43. "description": "Validate the schema, make no changes to the database."
  44. },
  45. {
  46. "value": "update",
  47. "description": "Update the schema if necessary."
  48. },
  49. {
  50. "value": "create",
  51. "description": "Create the schema and destroy previous data."
  52. },
  53. {
  54. "value": "create-drop",
  55. "description": "Create and then destroy the schema at the end of the session."
  56. }
  57. ]
  58. }
  59. ]}

每个”property”是一个配置节点,用户可以使用特定的值指定它。例如,server.portserver.servlet-path可能在application.properties中如以下定义:

  1. server.port=9090
  2. server.servlet-path=/home

“groups”是高级别的节点,它们本身不指定一个值,但为properties提供一个有上下文关联的分组。例如,server.portserver.servlet-path属性是server组的一部分。

:不需要每个”property”都有一个”group”,一些属性可以以自己的形式存在。