开发者

Can I use JAXRS annotations(for example @Produces) in an interface class in Grails

I am trying to create an interface class in Grails and implement that in a resource. I wanted to use the @Produces annotation in the interface class and use(implement) that in my resources class. I created my interface in src/groovy. But, it doesn't like the @Produces annotation, gives syntax error. My interface is something like this:

import javax.ws.rs.Produces

public interface annotationInterface {
@Produces开发者_如何转开发(['application/xml','application/json'])
}

Could anyone please tell me what I am doing wrong?

thanks


Your annotation does not annotate anything, that is why the compiler complains. javax.ws.rs.Produces can annotate methods or classes, so in your case I would think that

import javax.ws.rs.Produces

@Produces(['application/xml','application/json'])
public interface annotationInterface {

}

I cannot say if it makes sense though, because annotations are not inherited, so any class implementing the interface won't have that annotation. So unless there is a lookup for this annotation on implementing interfaces and/or super classes it won't work.


Did you used the Jax-rs plug-in ? If not, there will be a class path problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜