JDBC Backend
Spring Cloud Config Server 支持 JDBC(关系数据库)作为配置属性的后端。你可以通过将 spring-boot-starter-data-jdbc
添加到类路径并使用 jdbc
配置文件,或通过添加 JdbcEnvironmentRepository
类型的 bean 来启用此功能。如果你在类路径中包含正确的依赖关系(有关详细信息,请参阅用户指南),Spring Boot 会配置数据源。
Spring Cloud Config Server supports JDBC (relational database) as a backend for configuration properties.
You can enable this feature by adding spring-boot-starter-data-jdbc
to the classpath and using the jdbc
profile or by adding a bean of type JdbcEnvironmentRepository
.
If you include the right dependencies on the classpath (see the user guide for more details on that), Spring Boot configures a data source.
你可以通过将 spring.cloud.config.server.jdbc.enabled
属性设置为 false
来禁用 JdbcEnvironmentRepository
的自动配置。
You can disable autoconfiguration for JdbcEnvironmentRepository
by setting the spring.cloud.config.server.jdbc.enabled
property to false
.
数据库需要有一个名为 PROPERTIES
的表,其中包含名为 APPLICATION
、PROFILE
和 LABEL
的列(具有通常的 Environment
含义),以及 KEY
和 VALUE
来用于 Properties
样式的键值对。所有字段在 Java 中都是 String
类型,因此可以将它们创建为你需要的任何长度的 VARCHAR
。属性值的行为方式与它们来自名为 {application}-{profile}.properties
的 Spring Boot 属性文件时相同,包括所有加密和解密,这些操作将作为后处理步骤(即,不是直接在存储库实现中)应用。
The database needs to have a table called PROPERTIES
with columns called APPLICATION
, PROFILE
, and LABEL
(with the usual Environment
meaning), plus KEY
and VALUE
for the key and value pairs in Properties
style.
All fields are of type String in Java, so you can make them VARCHAR
of whatever length you need.
Property values behave in the same way as they would if they came from Spring Boot properties files named {application}-{profile}.properties
, including all the encryption and decryption, which will be applied as post-processing steps (that is, not in the repository implementation directly).
用于 JDBC 的默认标签是 |
The default label used for JDBC is |