Java 使用spring元注释的合成注释无效

Java 使用spring元注释的合成注释无效,java,spring,spring-mvc,annotations,Java,Spring,Spring Mvc,Annotations,我试图使用spring meta annotation@Mapping创建一个组合注释 @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Documented @Mapping public @interface RestQuery { RequestMethod[] method() default {RequestMethod.GET}; String[]

我试图使用spring meta annotation@Mapping创建一个组合注释

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Mapping
public @interface RestQuery {
    RequestMethod[] method() default {RequestMethod.GET};
    String[] produces() default {MediaType.APPLICATION_JSON_VALUE};
    String[] consumes() default {""};
    String[] value() default {};
    String[] params() default {};

}

@Controller
public class CustomerQueryController{
    @RestQuery(value="/test")
    public String test(){
        return "test";
    }
}
当我使用上述注释对spring控制器方法进行注释时,我得到一个异常,即URI没有映射。有什么想法吗,我错在哪里了

org.springframework.web.servlet.PageNotFound            | No mapping found for HTTP request with URI [/test/] in DispatcherServlet with name ''

我不知道您为什么使用
@映射
。Spring MVC只解析
@RequestMapping
。如果您查看源代码,RequestMapping是由映射组成的。我尝试过使用RequestMapping,但它在类级别不起作用。将更新问题?你所说的
@RequestMapping
在类级别不起作用是什么意思?根据你之前的评论,我实现了
@RestQuery
@RequestMapping
组合,而不是
@Mapping
。新注释
@RestQuery
应用于方法时有效,但应用于类时无效。