缺少方法的依赖关系 [英] Missing dependency for method

查看:83
本文介绍了缺少方法的依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行REST Web服务,添加了一些新的Web服务后,出现了一些错误. 为什么会出现这些错误?

I am running REST Web Service and after adding some new Web Services I got some errors. Why do I get these errors?

  SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
  SEVERE: Missing dependency for method public entities.ProyectoHasPersona service.ProyectoHasPersonaRESTFacade.find(entities.ProyectoHasPersonaPK) at parameter at index 0
  SEVERE: Method, public entities.ProyectoHasPersona service.ProyectoHasPersonaRESTFacade.find(entities.ProyectoHasPersonaPK), annotated with GET of resource, class service.ProyectoHasPersonaRESTFacade, is not recognized as valid resource method.
  SEVERE: Missing dependency for method public javax.ws.rs.core.Response service.ProyectoHasPersonaRESTFacade.remove(entities.ProyectoHasPersonaPK) at parameter at index 0
  SEVERE: Method, public javax.ws.rs.core.Response service.ProyectoHasPersonaRESTFacade.remove(entities.ProyectoHasPersonaPK), annotated with DELETE of resource, class service.ProyectoHasPersonaRESTFacade, is not recognized as valid resource method.

我正在使用Jersey 1.1.1,这些是我的依赖项:

I am using Jersey 1.1.1, these are my dependencies:

<dependencies>
    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>jsr311-api</artifactId>
        <version>1.1.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>osgi_R4_core</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

推荐答案

类似于方法service.ProyectoHasPersonaRESTFacade.find()和service.ProyectoHasPersonaRESTFacade.remove()带有一个未注释的参数(即,意味着方法期望请求实体传递给此参数),但是,这些方法映射到HTTP GET和DELETE. HTTP GET和HTTP DELETE都不能具有实体.因此,相应的Java方法上未注释的参数没有意义.

Looks like methods service.ProyectoHasPersonaRESTFacade.find() and service.ProyectoHasPersonaRESTFacade.remove() take one parameter which is not annotated (i.e. it means the methods expect the request entity to be passed into this parameter), however, these methods are mapped to HTTP GET and DELETE. Neither HTTP GET nor HTTP DELETE can have an entity. So the unannotated parameter on the corresponding Java methods does not make sense.

您可以获取要检索/删除的对象的ID/PK,例如通过将其放在路径参数或查询参数中.

You can get the ID/PK of the object to be retrieved/deleted e.g. by putting it either in a path parameter or query parameter.

这篇关于缺少方法的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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