java – Spring roo,field枚举

前端之家收集整理的这篇文章主要介绍了java – Spring roo,field枚举前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我是 Spring MVC和 Spring Roo的新手.

什么是字段枚举?

如何枚举所有允许的值?

它是使用查找表还是检查约束来实现?

解决方法

Roo的字段枚举–fieldName –type命令添加指定枚举类型的私有字段.

您可以手动创建枚举类型或使用roo命令:

roo> enum type --class ~.domain.Colors
roo> enum constant --name BLAU
roo> enum constant --name VERMELL

这将创建一个颜色枚举:

public Enum Colors {
  BLAU,VERMELL
}

然后可以使用枚举类型来定义实体字段:

roo> entity --class ~.domain.Foo
roo> field enum --fieldName color --type ~.domain.Colors

这将定义Foo实体:

//Annotations and imports ommited for brevity
public class Foo{
     private Colors color;
}

有关roo命令的完整参考,请参见http://static.springsource.org/spring-roo/reference/html/command-index.html.

原文链接:https://www.f2er.com/java/125802.html

猜你在找的Java相关文章