首页 文章

类型[*** <T>]的不满意依赖关系,在注入点[[field] @Inject使用限定符[@Default]

提问于
浏览
1

当部署到jboss arquilian服务器时,我遇到了以下问题(当我部署本地jboss服务器时,我似乎没有这个问题)

org.jboss.weld.exceptions.DeploymentException:WELD-001408类型[CarPolicyServiceWithContext]的不满足依赖关系,注入点带有限定符[@Default] [[field] @Inject com.athlon.thrift.web.utils.MSFOTContextUtils.carPolicyService]

注射

@ApplicationScoped
public class MSFOTContextUtils {

    @Inject
    Logger logger;

    @Inject
    CarPolicyServiceWithContext carPolicyService;

提供者

@ApplicationScoped
public class ServiceProvider {

    @Inject
    @Any
    private Instance<CarPolicyServiceWithContext> carPolicyServices;



    private static final String COUNTRY = "NL";
    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceProvider.class);

     @Produces
    public CarPolicyServiceWithContext getCarPolicyService() {
        Instance<CarPolicyServiceWithContext> found = carPolicyServices.select(
                new CountryQualifier(COUNTRY));
        LOGGER.info("CarPolicyServiceWithContext loaded"+found.toString());
        return found.get();
    }

    public static class CountryQualifier
            extends AnnotationLiteral<Country>
            implements Country {
        private String value;

        public CountryQualifier(String value) {
            this.value = value;
        }

        public String value() {
            return value;
        }
    }
}

beans

@Country("NL")
@ApplicationScoped
public class CarPolicyNetherlandsService implements CarPolicyServiceWithContext<MSFOTContext> {

我在提供程序中添加了一些日志记录,但我没有在arquillian jboss日志中看到它...

谢谢 !

1 回答

  • 0

    在@Deployment存档中,由于某种原因,上面的ServiceProvider类未添加到存档中 .

相关问题