类型Set< Service>的不满足的依存关系带预选赛 [英] Unsatisfied dependencies for type Set<Service> with qualifiers

查看:78
本文介绍了类型Set< Service>的不满足的依存关系带预选赛的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始创建Web服务(Restful api).遵循Java Brains for Restful Web服务的简单教程. 我收到了这样的错误消息:带限定符@Default的类型Set的不满意依赖项"

I am new to work on the creation of web services(Restful api). following a simple tutorial of Java Brains for Restful web services. I am Getting the error which says something like "Unsatisfied dependencies for type Set with qualifiers @Default"

我在这里搜索了其他问题,并尝试了以下方法:

I have searched for different questions here, have tried below things:

  1. 下载新服务器并将其连接到我的项目并删除旧服务器.
  2. 更新了番石榴的依赖关系并将其jar添加到我的项目中.

仍然面对错误.

下面是服务器错误日志.

below is the server error log.

严重:加载应用程序时发生异常:CDI部署 失败:WELD-001408:类型集的不满意依赖性 在注入点使用限定符@Default [BackedAnnotatedParameter] [BackedAnnotatedConstructor]的参数1 @Inject com.google.common.util.concurrent.ServiceManager(Set) 在 com.google.common.util.concurrent.ServiceManager.(ServiceManager.java:0) org.jboss.weld.exceptions.DeploymentException:WELD-001408: 带限定符的Set类型的依赖关系不令人满意 @默认在注入点[BackedAnnotatedParameter]参数1 [BackedAnnotatedConstructor]的@Inject com.google.common.util.concurrent.ServiceManager(Set)在 com.google.common.util.concurrent.ServiceManager.(ServiceManager.java:0)

Severe: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Set with qualifiers @Default at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject com.google.common.util.concurrent.ServiceManager(Set) at com.google.common.util.concurrent.ServiceManager.(ServiceManager.java:0) org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Set with qualifiers @Default at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject com.google.common.util.concurrent.ServiceManager(Set) at com.google.common.util.concurrent.ServiceManager.(ServiceManager.java:0)

这是提供数据的学生服务类.

this is studentservice class which is providing data.

public class StudentService {
    public List<Student> getAllData() {
        Student s1 = new Student(1, "Sagar", 20);
        Student s2 = new Student(2, "Puneet", 23);
        List<Student> list = new ArrayList<>();
        list.add(s1);
        list.add(s2);
        return list;
    }
}

下面是我的api类

@Path("/myfirstapi")
public class MyFirstAPI {
StudentService ss=new StudentService();
@GET
@Produces(MediaType.APPLICATION_XML)
public List<Student> gettext() {
    return ss.getAllData();
    }
}

推荐答案

此错误的原因通常是番石榴的错误版本.您可能具有Guava<的版本. 16.您应该检查您的类路径.

The cause of this error is usually a bad version of Guava. You may have a version of Guava < 16. You should check your classpath.

我可以看到2个解决方案:

I can see 2 solutions :

  • 如果您正在使用CDI(似乎没有使用),请用> = 16更新Guava版本.
  • 否则禁用CDI(如果类路径中存在bean,请删除bean.xml,并在应用程序服务器中禁用隐式扫描).

这篇关于类型Set&lt; Service&gt;的不满足的依存关系带预选赛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆