简体   繁体   English

Spring Roo可以解析注释@ javax.validation.constraints.Size的参数中的变量吗?

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

i have a spring roo application with an entity Book . 我有一个带有实体Book的spring roo应用程序。 the entity has some properties like title where i use a variable ONE_KILO_BYTE as value: 该实体具有一些属性,例如标题 ,其中我使用变量ONE_KILO_BYTE作为值:

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. 代码可以编译并运行良好,但是在Spring Roo Shell中我遇到了一些错误,并且Roo Shell无法再更新诸如Book_Roo_Jpa_ActiveRecord.aj之类的相应aj文件。 the error message in spring roo shell looks like this: spring roo shell中的错误消息如下所示:

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. 当我用1024 spring roo替换所有ONE_KILO_BYTE的出现时 ,能够再次生成aj文件。

roo version: 1.2.5.RELEASE roo版本:1.2.5.RELEASE

my problem remembers me a bit of this issue: https://jira.spring.io/browse/ROO-3047 我的问题让我想起了这个问题: https : //jira.spring.io/browse/ROO-3047

is it possible to use constant values in @Size annotation arguments with spring roo? Spring Roo是否可以在@Size注释参数中使用常量值?

It isn't possible. 这是不可能的。 The reason is that Roo MetaModel needs the value for generating code. 原因是Roo MetaModel需要用于生成代码的值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有找到约束&#39;javax.validation.constraints.Size&#39;的验证器 - No validator could be found for constraint 'javax.validation.constraints.Size' 可以为 FLOAT 的约束“javax.validation.constraints.Size”找到节点验证器 - Node validator could be found for constraints 'javax.validation.constraints.Size' for FLOAT 没有找到约束'javax.validation.constraints.Size'验证类型'java.lang.Double'的验证器 - No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.lang.Double' HV000030:找不到约束&#39;javax.validation.constraints.Size&#39;的验证器,验证类型&#39;java.util.Map&#39; - HV000030: No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.util.Map' HV000030:找不到约束“javax.validation.constraints.Size”验证类型“java.util.Optional”的验证器<java.lang.String> &#39; - HV000030: No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.util.Optional<java.lang.String>' 在Roo项目中使用javax.persistence.Table @Table批注,如何使用Maven(或Spring)从构建配置文件设置架构? - Using javax.persistence.Table @Table annotation in roo project, how can I use maven (or spring) to set the schema from a build profile? javax 验证约束在 Spring Boot 中不起作用 - javax validation constraints not working in Spring Boot Javax验证大小注释行为不正确 - Javax Validation Size annotation does not behave correctly 大小验证最大值为{javax.validation.constraints.Size.message} - Size validation max value is {javax.validation.constraints.Size.message} Spring javax.validation批注未在BindingResult中捕获 - Spring javax.validation annotation not caught in BindingResult
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM