【问题标题】:Google Guice: Provider with parametersGoogle Guice:带参数的提供者
【发布时间】:2011-02-09 17:57:12
【问题描述】:

我有一个依赖于类 A 和 B 的构造函数。我这样定义它:

@Inject TestClass(A a, B b)

Guice 中有没有办法手动注入其中一个构造函数参数?

问题是,A 类的对象无法构建,因为它取决于用户输入。我只是想知道 Guice 是否支持接受参数的提供程序。比如目前provider.get()可以创建一个对象,Guice有没有支持provider.get(a)的对象?

【问题讨论】:

    标签: java dependency-injection guice


    【解决方案1】:

    我想你需要的是Assisted Inject

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-27
      • 1970-01-01
      • 2019-07-24
      • 2019-10-09
      • 2013-08-05
      • 1970-01-01
      相关资源
      最近更新 更多