Java JAX-RS @PUT注释不是继承的

时间:2013-10-22 16:14:29

标签: java java-ee annotations jax-rs

我有一个抽象类,声明了@PUT方法:

public abstract class BaseResource<T> {

  @PUT
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public abstract Response create(T entityClass);

}

然后一个类实现该方法:

public class GroupsResource extends BaseResource<Group> {

  @Override
  public Response create(Group newGroup) {

    // this works.
    // ...
    return response.build();

  }
}

使用GET方法的类似代码可以正常工作,但是这个代码被 405 Method Not Allowed 拒绝。但是,如果我使用@PUT注释实现,它确实有用。所以似乎抽象声明中的@PUT注释没有被继承。

有什么想法吗?

更新:

我已经从头开始使用Java EE7,这非常有用。

1 个答案:

答案 0 :(得分:0)

我在项目中遇到了同样的问题,我这样解决了它:

var editor$;
tinymce.init({
  selector: '#editorcontent',
  height: 500,
  theme: 'modern',
  plugins: 'print preview fullpage powerpaste searchreplace autolink directionality advcode visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists textcolor wordcount tinymcespellchecker a11ychecker imagetools mediaembed  linkchecker contextmenu colorpicker textpattern help',
  toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify  | numlist bullist outdent indent  | removeformat | code ',
  image_advtab: true,
  templates: [
    { title: 'Test template 1', content: 'Test 1' },
    { title: 'Test template 2', content: 'Test 2' }
  ],
  content_css: [
    '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
    '//www.tinymce.com/css/codepen.min.css'
  ],
  init_instance_callback: function (editor) {
    editor$ = editor;
  }
 });
 setTimeout(()=>{
   let ed=tinymce.get('editorcontent');
   ed.setContent("<h1>Hello Duniya</h1>");
 },1000);