相关疑难解决方法(0)

覆盖子上下文中父上下文中定义的bean

我们的应用程序需要支持多租户.每个登机客户都可能会覆盖一个或多个bean或核心平台级别定义的bean的某些属性(公共代码/定义).我想知道处理这个问题的最佳方法是什么.

architecture spring java-ee multi-tenant

22
推荐指数
1
解决办法
2万
查看次数

覆盖java配置中的bean定义

我有一个configuartion课程

@Configuration
public class FooConfig{
  @Bean
  public FooService fooService() { ... }
  @Bean
  public AbcService abcService() { ... }
}
Run Code Online (Sandbox Code Playgroud)

该类在lib中定义,我无法更改.我有一个项目,FooService在很多地方使用.在我的项目中,我有另一个配置类

@Configuration
@Import({
  FooConfig.class,

})
public class BarConfig{
  @Autowired AbcService abc;
  ...    
}
Run Code Online (Sandbox Code Playgroud)

AbcService这里使用的是因为有些服务依赖于该服务并且声明了服务BarConfig.但是,FooService此处未使用(仅在控制器中使用)

我需要改变执行FooService.我可以定义新的FooServicebean BarConfig吗?它是否会覆盖通过导入的已存在的定义FooConfig

java spring

14
推荐指数
1
解决办法
3万
查看次数

标签 统计

spring ×2

architecture ×1

java ×1

java-ee ×1

multi-tenant ×1