首页 > 编程语言 > 详细

spring roo初体验

时间:2015-12-10 13:00:52      阅读:185      评论:0      收藏:0      [点我收藏+]

1、下载spring-roo-2.0.0.M1,并执行如下命令,在/usr/local/bin下面建立一个roo的软连接
 
sudo ln -s /Users/pud/Documents/still/spring/roo/spring-roo-2.0.0.M1/bin/roo.sh /usr/local/bin/roo
 
2、在sts的dashborad里面安装roo插件,注意sts的版本是3.7.2.RELEASE,之前用的是3.6.3,咋装装不上。
 
3、在sts中创建一个spring roo工程。
 
4、创建连接数据库
persistence setup --provider HIBERNATE --database MYSQL --userName root --password 123456 --databaseName conference
 
5、创建实体
entity jpa --class ~.domain.Speaker --testAutomatically
entity jpa --class ~.domain.Talk --testAutomatically
 
6、为实体添加字段
field string --fieldName firstname --class ~.domain.Speaker --notNull
field string --fieldName lastname --notNull
field string --fieldName email --unique --notNull
field string --fieldName organization
field date --fieldName birthdate --type java.util.Date --past --notNull
field number --type java.lang.Long --fieldName age --min 25 --max 60
 
field string --fieldName title --class ~.domain.Talk --notNull
field string --fieldName description --notNull --sizeMax 4000
 
7、为实体增加关联关系
field set --fieldName talks --type com.dw.roo.conference.domain.Talk --class com.dw.roo.conference.domain.Speaker --mappedBy speaker --notNull false --nullRequired false --cardinality ONE_TO_MANY --transient false --permitReservedWords false
 
field reference --fieldName speaker  --type com.dw.roo.conference.domain.Speaker --class com.dw.roo.conference.domain.Talk --notNull true --nullRequired false --transient false --permitReservedWords false 
 
8、增加controller
controller all --package ~.web
 
9、添加日志
logging setup --level INFO --package ALL_SPRING

 

spring roo初体验

原文:http://www.cnblogs.com/puroc/p/5035550.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!