Ara*_*ram 22 architecture spring java-ee multi-tenant
我们的应用程序需要支持多租户.每个登机客户都可能会覆盖一个或多个bean或核心平台级别定义的bean的某些属性(公共代码/定义).我想知道处理这个问题的最佳方法是什么.
ska*_*man 33
Spring allows you to redefine the same bean name multiple times, and takes the last bean definition processed for a given name to be the one that wins. So for example, your could have an XML file defining your core beans, and import that in a client-specific XML file, which also redefines some of those beans. It's a bit fragile, though, since there's no mechanism to specifically say "this bean definition is an override".
I've found that the cleanest way to handle this is using the new @Bean
-syntax introduced in Spring 3. Rather than defining beans as XML, you define them in Java. So your core beans would be defined in one @Bean
-annotated class, and your client configs would subclass that, and override the appropriate beans. This allows you to use standard java @Override
annotations, explicitly indicating that a given bean definition is being overridden.
归档时间: |
|
查看次数: |
24089 次 |
最近记录: |