我正在使用 Spring Data 和 Gemfire 开发数据服务。有注释
@Region("<region name>")
指定 POJO 将存储在哪个 Gemfire 区域。
它需要配置的 Gemfire 区域的名称。我觉得硬编码区域名称是一种不好的做法,因为 Gemfire 集群将由一个单独的团队管理,我相信区域名称应该是完全可配置的。
有没有更好的做法来避免对区域名称进行硬编码?
我正在使用 Spring Data 和 Gemfire 开发数据服务。有注释
@Region("<region name>")
指定 POJO 将存储在哪个 Gemfire 区域。
它需要配置的 Gemfire 区域的名称。我觉得硬编码区域名称是一种不好的做法,因为 Gemfire 集群将由一个单独的团队管理,我相信区域名称应该是完全可配置的。
有没有更好的做法来避免对区域名称进行硬编码?
The region name must be shared by all processes that access the region. This is analogous to a table name in a relational database. In this sense, it is no different than JPA or Hibernate annotations that declare the table name in which the POJO will be stored. IIRC, using Spring Data Repositories, if @Region is not present it will get it from the class name. But either way, the corresponding region must exist. If your application is a client to the GemFire grid, you must also configure a client region with the same name as the corresponding region on the server. If it's a peer than you must create the region (either a partition or a replica). These things may be done with Spring configuration or native GemFire configuration, but in any event, the shared region name must be known in advance and if it changes, it must change everywhere.
可以使用 Spring Expression Language 来注入 Region 的名称吗?
我们将一个基于 XML 文件的配置 bean 中的值注入到 @Value 注释中,例如:
@Value("#{config.dataSourceConfig.dbMainUsername}")
其中“config”是配置 bean 的名称。
不确定这是否适用于所有注释...