Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java-使用参数定义注释的名称_Java_Annotations - Fatal编程技术网

Java-使用参数定义注释的名称

Java-使用参数定义注释的名称,java,annotations,Java,Annotations,我经常使用带有复杂参数的注释,例如: @CookieValue(value = SomeClass.SOME_STATIC_FIELD, required = false) UUID cookieValue 是否可以为该注释定义一个新名称,以便可以像这样替换上述内容 @MyCookieValue UUID cookieValue 基于此,我尝试了以下方法:不幸的是,语法不正确 @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.

我经常使用带有复杂参数的注释,例如:

@CookieValue(value = SomeClass.SOME_STATIC_FIELD, required = false) UUID cookieValue
是否可以为该注释定义一个新名称,以便可以像这样替换上述内容

@MyCookieValue UUID cookieValue
基于此,我尝试了以下方法:不幸的是,语法不正确

@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyCookieValue {
    CookieValue cookieValue(value = SomeClass.SOME_STATIC_FIELD, required = false);
}

您是否尝试过:
@Target(ElementType.PARAMETER)@Retention(RetentionPolicy.RUNTIME)@CookieValue(value=SomeClass.SOME\u STATIC\u FIELD,required=false)public@interface MyCookieValue{}
?它显示错误消息:
此位置不允许注释@CookieValue
。Spring
@CookieValue
仅适用于参数。