문제

I know that Instance is not part of JSR 330, but is there a Spring equivalent? I'm interested in the fact that Instance implements Iterable, so Provider will not be the correct answer.

public interface Report { ... }

(there are 2 classes implementing Report with @Named annotations)

@Named
public class ReportRunner {
    @Inject private Instance<Report> reports;
}

results in: No qualifying bean of type [javax.enterprise.inject.Instance] found for dependency...

도움이 되었습니까?

해결책

Closing this question out because it has been answered in comments. As @JB Nizet mentioned above, List<Report> works.

For those that wonder what I was doing, it was a generic report runner, wherein each report has its own implementing class, each with a set of DB stored parameters. With this set up, I can leave the report runner running in my app server, drop in jars as necessary, hit re-scan on the sub-context that the ReportRunner maintains (which scans only the Reporting package) and I can modify reports on the fly, without a server restart.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top