给出了 2 个 Sling 模型,我想注入其中一个。这是否可以通过注释实现,或者我是否需要创建 PostContruct 方法作为解决方法?
例子:
A型
@Model(adaptables = Resource.class)
public class ModelA {
@ValueMapValue(name = "jcr:title", injectionStrategy = InjectionStrategy.OPTIONAL)
private String title;
@Inject // Not working!
private ModelB modelB;
}
B型
@Model(adaptables = Resource.class)
public class ModelB {
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
private String text;
}