小编Lea*_*dao的帖子

Quarkus 不以编程方式选择 bean

我试图以编程方式选择 bean,但 quarkus 不会注入 bean 并引发异常。不支持吗?

public enum ReportType {
    ONE,
    TWO
}
Run Code Online (Sandbox Code Playgroud)
@Qualifier
@Retention(RUNTIME)
@Target({METHOD, PARAMETER, FIELD, TYPE})
@Documented
public @interface Report {

    ReportType value();

    public static final class Literal extends AnnotationLiteral<Report> implements Report {

        private final ReportType value;

        public static Literal of(ReportType value) {
            return new Literal(value);
        }

        private Literal(ReportType value) {
            this.value = value;
        }

        public ReportType value() {
            return value;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)
public interface CommonnInterface {
    void call();
}
Run Code Online (Sandbox Code Playgroud)
@Report(value = ReportType.ONE)
public class ReportOneBusiness …
Run Code Online (Sandbox Code Playgroud)

java cdi quarkus

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

标签 统计

cdi ×1

java ×1

quarkus ×1