Emi*_*mir 10 java spring-mvc spring-roo
我是Spring MVC和Spring Roo的新手.
什么是字段枚举?
如何枚举所有允许的值?
它是使用查找表还是检查约束实现的?
Ser*_*ipc 22
Roo的field enum --fieldName --type命令添加了指定枚举类型的私有字段.
您可以手动创建枚举类型或使用roo命令:
roo> enum type --class ~.domain.Colors
roo> enum constant --name BLAU
roo> enum constant --name VERMELL
Run Code Online (Sandbox Code Playgroud)
这会创建一个Colors枚举:
public Enum Colors {
BLAU, VERMELL
}
Run Code Online (Sandbox Code Playgroud)
然后你可以使用then枚举类型来定义实体字段:
roo> entity --class ~.domain.Foo
roo> field enum --fieldName color --type ~.domain.Colors
Run Code Online (Sandbox Code Playgroud)
这将定义Foo实体:
//Annotations and imports ommited for brevity
public class Foo{
private Colors color;
}
Run Code Online (Sandbox Code Playgroud)
有关roo命令的完整参考,请参见http://static.springsource.org/spring-roo/reference/html/command-index.html.
| 归档时间: |
|
| 查看次数: |
7067 次 |
| 最近记录: |