grails - 在域类之前grails @Resource Annotation

标签 grails

在Grails中创建RESTful API时,我在域类之前添加了@Resource(uri='env',formats=['multipart/form-data']。然后使用grails generate-all domain_name生成 Controller 和 View 。

但是,在Eclipse中有一个Java问题,例如

The project was not built due to "RequestEnvironmentController$_on_closure51 [in [Working copy] RequestEnvironment.groovy [in test.environment.manager [in grails-app/domain [in restful-api-for-tem]]]] does not exist". Fix the problem, then try refreshing this project and building it since it may be inconsistent.



然后,我摆脱了注释,错误消失了,并且post方法仍然有效。我很困惑,注释是否必要?如有必要,如何清除Java错误?

最佳答案

使用@Resource批注时,无需创建 Controller ,因为它将根据documentation自动生成

Simply by adding the Resource transformation and specifying a URI, your domain class will automatically be available as a REST resource in either XML or JSON formats. The transformation will automatically register the necessary RESTful URL mapping and create a controller called BookController.

关于grails - 在域类之前grails @Resource Annotation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31438154/

相关文章:

grails - 如何从Request中检索cxf Web服务中的 header 参数?

grails - Grails 应用程序中有许多持久的 CLOSE_WAIT 连接

Grails GORM 'or' 不与关联一起工作

grails - Grails JMS消息无法使用Spring Security添加权限

javascript - 将文件上传到Google文档

grails - 如何在PCFDev中查看Tomcat日志?

hibernate - 在Hibernate中将两个表与BigInteger数据类型相关联时出错

grails - Grails命令对象中的可选可空字段

grails - Grails Heroku部署错误

Grails 批量插入/更新优化