简体   繁体   中英

can spring roo parse variables in arguments of annotation @javax.validation.constraints.Size?

i have a spring roo application with an entity Book . the entity has some properties like title where i use a variable ONE_KILO_BYTE as value:

public class Book {

 private static final int ONE_KILO_BYTE = 1024;

 @NotNull
 @Size(max = ONE_KILO_BYTE)
 private String title;
 ...
}

the code compiles and works well, but in spring roo shell i get some errors and the corresponding aj file like Book_Roo_Jpa_ActiveRecord.aj can no more be updated by the roo shell. the error message in spring roo shell looks like this:

org.springframework.roo.model.EnumDetails cannot be cast to java.lang.Integer

when i replace all occurences of ONE_KILO_BYTE with 1024 spring roo is able to generate aj files again.

roo version: 1.2.5.RELEASE

my problem remembers me a bit of this issue: https://jira.spring.io/browse/ROO-3047

is it possible to use constant values in @Size annotation arguments with spring roo?

It isn't possible. The reason is that Roo MetaModel needs the value for generating code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM