相关疑难解决方法(0)

是否可以在@RequiredArgsConstructor中添加限定符(onConstructor = @__(@ Autowired))?

如果我想@Qualifier在构造函数依赖注入上使用注释,我会有以下内容:

public class Example {

    private final ComponentExample component;

    @Autowired
    public Example(@Qualifier("someComponent") ComponentExample component) {
        this.component = component;
    }
}
Run Code Online (Sandbox Code Playgroud)

我知道lombok注释减少样板代码而不必包含构造函数如下:@RequiredArgsConstructors(onConstructor=@__(@Inject))但这仅适用于没有限定符的属性.

有人知道是否可以添加限定符@RequiredArgsConstructor(onConstructor = @__(@Autowired))

java spring dependency-injection lombok

29
推荐指数
3
解决办法
8852
查看次数

标签 统计

dependency-injection ×1

java ×1

lombok ×1

spring ×1