我在我的WebProject中为我的一个模型类添加了一个Custom java annotation。现在的问题是,如果我将类保留在我的项目战争的引用模块jar中,我将无法获取模型类中添加的字段级自定义注释。如果将类作为同一项目战争的一部分保存在我获取所有注释的位置,它可以正常工作。我甚至将保留策略标记为" RUNTIME"但它没有帮助。任何想法,这里有什么不对。
public class SalesUploadData {
@ExcelColumn(position = 0)
private Integer countryCode;
@ExcelColumn(position = 1)
private Integer currencyCode;
@ExcelColumn(position = 2)
private String serialNumber;
public Integer getCountryCode() {
return countryCode;
}
public void setCountryCode(Integer countryCode) {
this.countryCode = countryCode;
}
}
@Documented
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = ElementType.FIELD)
public @interface ExcelColumn {
String name() default "";
int position();
String dateFormat() default "";
boolean isMandatory() default false;
}
我正在服务器中部署两个WAR,如下图所示。
答案 0 :(得分:0)
正如评论中提到的,解决方案是将<attachClasses>true</attachClasses>
添加到maven-war-plugin以生成一个额外的工件,其中只包含 module-classes.jar中的Web模块的类。 存档,用作其他模块中的依赖项。