Java 用反射动态给excel导出类修改注解报错?

用的easyExcel 这个注解value是String[],这边方法传的也是String[] 出现了传参报错

java.lang.RuntimeException: java.lang.IllegalArgumentException: wrong number of arguments
@Target({ElementType.FIELD})

@Retention(RetentionPolicy.RUNTIME)

@Inherited

public @interface ExcelProperty {

String[] value() default {""};

int index() default -1;

int order() default Integer.MAX_VALUE;

Class<? extends Converter<?>> converter() default AutoConverter.class;

/** @deprecated */

@Deprecated

String format() default "";

}

ExcelProperty annotation = DogImport.class.getDeclaredField("field").getAnnotation(ExcelProperty.class);

String[] datas = new String[]{"new value"};

setAnnotationValue(annotation, "value", datas);

public static void setAnnotationValue(Object annotation, String propertyName, Object value) throws Exception {

Method valueMethod = annotation.getClass().getDeclaredMethod(propertyName);

valueMethod.setAccessible(true);

valueMethod.invoke(annotation,(Object) value);

}

以上是 Java 用反射动态给excel导出类修改注解报错? 的全部内容, 来源链接: utcz.com/p/945540.html

回到顶部