Netbeans Restful Web 服务中缺少方法公共实体的依赖关系
我正在使用 Netbeans EE6 和 jersey 库以及教程 http://netbeans 部署宁静的 Web 服务.org/kb/docs/websvc/rest.html。
当我从数据库中保存复合主键的实体创建静态 Web 服务时,当我尝试测试 Web 服务时,项目会给出错误:
严重:索引 0 处的参数处缺少方法公共Entity.RMSchedule service.RMScheduleFacadeREST.find(entities.RMSchedulePK) 的依赖关系 严重:使用资源类 service.RMScheduleFacadeREST 的 GET 注释的公共实体.RMSchedule service.RMScheduleFacadeREST.find(entities.RMSchedulePK) 方法未被识别为有效的资源方法。
该错误是由于复合主键造成的还是我应该包括一个步骤? 非常感谢。
I am deploying a restful web services using Netbeans EE6 and jersey libraries with the tutorial http://netbeans.org/kb/docs/websvc/rest.html.
When I create a restful web services from entities that hold composite primary keys in the database, the project gives me an error when I try to test the web services:
SEVERE: Missing dependency for method public entities.RMSchedule service.RMScheduleFacadeREST.find(entities.RMSchedulePK) at parameter at index 0
SEVERE: Method, public entities.RMSchedule service.RMScheduleFacadeREST.find(entities.RMSchedulePK), annotated with GET of resource, class service.RMScheduleFacadeREST, is not recognized as valid resource method.
Is the error due to composite primary keys or is there a step that I should include?
Many thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这个问题与 Netbeans bug 有关:
https://netbeans.org/bugzilla/show_bug .cgi?id=208375
创建具有复合主键的实体类时,
创建两个实体文件。
(ex CustomerEntity.jave, CustomerEntityPK.java)
然后,如果您选择从实体类创建 servlet,则该 servlet 会自动生成如下代码:
问题在于该参数是传递给 servlet 方法的是 CustomerEntityPK,它具有复合主键。
如果将参数类型更改为类似 String 的类型,那么在我的例子中错误就会消失。
但在我的项目中,我不需要这样的自动生成的代码,所以我只是选择手动创建 servlet 类,没有问题。
希望有帮助。
I think this issue is related to Netbeans bug:
https://netbeans.org/bugzilla/show_bug.cgi?id=208375
When creating entity class which has composite primary keys,
two entity files are created.
(ex CustomerEntity.jave, CustomerEntityPK.java)
Then if you choose to create the servlet from the entity class, the servlet comes with automatically generated code such as below:
The issue is that argument being passed to the servlet methods is CustomerEntityPK which has composite primary key.
If you change the argument type to something like String then the error went away in my case.
But in my project I did not need such auto generated code so I simply choose to create servlet class by hand and has no problem.
Hope that helps.