* Much easier installation
* 31% better performance
* Tomcat support (for embedded usage)
* JMS support (including ActiveMQ setup)
* Selenium support
* Email support
* Web Flow installation
* Additional samples
* Various other fixes and improvements
在 Spring Roo 提供完整的官方文档之前 ,SpringSource 网站博客上提供入门文章 便是不可多得的学习资料,我这里也是根据文章进行操作的。
从 SpringSource 网站上下载 Spring ROO 1.0.0 m1 ,解压到硬盘上。
将 <spring_roo_dir>/bin 加入到系统的PATH变量中。在 Linux 系统上,你可以直接创建一个链接到 ~/bin 或 /usr/bin/ 中。
Welcome to Spring Roo. For assistance press TAB or type "hint" then hit ENTER.
任何时候你可以输入hint 来获得一些操作建议。
roo> hint
Welcome to Roo! We hope you enjoy your stay!
Before you can use many features of Roo, you need to start a new project.
To do this, type 'create project' (without the quotes) and then hit TAB.
Enter a -topLevelPackage like 'com.mycompany.projectname' (no quotes).
When you've finished completing your -topLevelPackage, press ENTER.
Your new project will then be created in the current working directory.
Note that Roo frequently allows the use of TAB, so press TAB regularly.
Once your project is created, type 'hint' and ENTER for the next suggestion.
You're also welcome to visit http://forum. for Roo help.
roo> cre
这时按 Tab 键,你会发现 Spring Roo 会帮你自动补全命令 create project。
Linux 用户对 Tab 的使用再也熟悉不过了,在 Spring Roo 的命令行,你随时都使用 tab 来辅助命令的输入。
roo> create project
这里按下 enter ,会得到一条提示信息。
You must specify a default option (otherwise known as option 'topLevelPackage') for this command
roo> create project -topLevelPackage roodemo
Created /home/hantsy/Projects/roodemo/pom.xml
Created SRC_MAIN_JAVA
Created SRC_MAIN_RESOURCES
Created SRC_TEST_JAVA
Created SRC_TEST_RESOURCES
Created SRC_MAIN_WEBAPP
Created SRC_MAIN_RESOURCES/applicationContext.xml
Created SRC_MAIN_WEBAPP/WEB-INF
Created SRC_MAIN_WEBAPP/WEB-INF/roodemo-servlet.xml
Created SRC_MAIN_WEBAPP/WEB-INF/web.xml
Created SRC_MAIN_WEBAPP/WEB-INF/jsp
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/index.jsp
Created SRC_MAIN_WEBAPP/WEB-INF/urlrewrite.xml
这里如果输入hint,会得到以下信息。
roo> hint
Roo requires the installation of a JPA provider and associated database.
Type 'install jpa' and then hit TAB three times.
We suggest you type 'H' then TAB to complete "HIBERNATE".
After the -provider, press TAB twice for database choices.
For testing purposes, type (or TAB) HYPERSONIC_IN_MEMORY.
If you press TAB again, you'll see there are no more options.
As such, you're ready to press ENTER to execute the command.
Once JPA is installed, type 'hint' and ENTER for the next suggestion.
任何时候,不要忘记使用 hint 来获得提示。
roo> install jpa -
按 tab 可以看到所提供的参数选项。
install jpa -database install jpa -provider
输入 -p 按 tab 自动补全 -provider 。
roo> install jpa -provider
按 tab 可以看到几种可用的 jpa 实现。
ECLIPSELINK HIBERNATE OPENJPA
接着输入首字母 H 按tab,补全 HIBERNATE,再输入-d 按 tab,补全-database。
roo> install jpa -provider HIBERNATE -database
H2_IN_MEMORY HYPERSONIC_IN_MEMORY HYPERSONIC_PERSISTENT
MSSQL MYSQL ORACLE
POSTGRESQL SYBASE
最后输入MY 按 tab 选择MySQL 数据库。
roo> install jpa -provider HIBERNATE -database MYSQL
Created SRC_MAIN_RESOURCES/META-INF
Created SRC_MAIN_RESOURCES/META-INF/persistence.xml
Created SRC_MAIN_RESOURCES/database.properties
please enter your database details in src/main/resources/database.properties
Managed SRC_MAIN_RESOURCES/applicationContext.xml
Managed ROOT/pom.xml
Managed ROOT/pom.xml
Managed ROOT/pom.xml
Managed ROOT/pom.xml
Managed ROOT/pom.xml
Managed ROOT/pom.xml
Managed ROOT/pom.xml
Managed ROOT/pom.xml
Managed ROOT/pom.xml
Managed ROOT/pom.xml
roo> hint
You can create entities either via Roo or your IDE.
Using the Roo shell is fast and easy, especially thanks to the TAB completion.
Start by typing 'new p' and then hitting TAB twice.
Enter the -name in the form '~.domain.MyEntityClassName'
In Roo, '~' means the -topLevelPackage you specified via 'create project'.
Afer specify a -name argument, press SPACE then TAB. Note nothing appears.
Because nothing appears, it means you've entered all mandatory arguments.
However, optional arguments do exist for this command (and most others in Roo).
To see the optional arguments, type '-' and then hit TAB. Mostly you won't
need any optional arguments, but let's select the -testAutomatically option
and hit ENTER. You can always use this approach to view optional arguments.
After creating an entity, use 'hint' for the next suggestion.
创建一个 Post 类。
roo> new persistent class jpa -name ~.domain.Post -
按下 Tab ,你有三种选择,你可以创建一个抽象类,或者从其它类继承。
new persistent class jpa -name ~.domain.Post -abstract
new persistent class jpa -name ~.domain.Post -extends
new persistent class jpa -name ~.domain.Post -testAutomatically
这里输入 t 按 Tab 键选择 -testAutomatically 同时创建一个测试类。
roo> new persistent class jpa -name ~.domain.Post -testAutomatically
Created SRC_MAIN_JAVA/roodemo/domain
Created SRC_MAIN_JAVA/roodemo/domain/Post.java
Created SRC_TEST_JAVA/roodemo/domain
Created SRC_TEST_JAVA/roodemo/domain/PostDataOnDemand.java
Created SRC_TEST_JAVA/roodemo/domain/PostIntegrationTest.java
Created SRC_MAIN_JAVA/roodemo/domain/Post_Roo_Plural.aj
Created SRC_MAIN_JAVA/roodemo/domain/Post_Roo_Entity.aj
Created SRC_MAIN_JAVA/roodemo/domain/Post_Roo_ToString.aj
Created SRC_MAIN_JAVA/roodemo/domain/Post_Roo_Configurable.aj
Created SRC_TEST_JAVA/roodemo/domain/PostIntegrationTest_Roo_Configurable.aj
Created SRC_TEST_JAVA/roodemo/domain/PostDataOnDemand_Roo_DataOnDemand.aj
Created SRC_TEST_JAVA/roodemo/domain/PostIntegrationTest_Roo_IntegrationTest.aj
Created SRC_TEST_JAVA/roodemo/domain/PostDataOnDemand_Roo_Configurable.aj
roo> add field string -fieldName title -notNull -sizeMax 200
roo> add field string -fieldName content -notNull -sizeMax 2000
roo> add field date jpa -fieldName createdDate -type java.util.Date
roo> add field date jpa -fieldName modifiedDate -type java.util.Date
创建另外一个类 Comment。
roo> new persistent class jpa -name ~.domain.Comment -testAutomatically
roo> add field string -fieldName name -notNull -sizeMax 200
roo> add field string -fieldName email -notNull -sizeMax 50
roo> add field string -fieldName content
roo> add field string -fieldName url
roo> add field date jpa -fieldName createdDate -type java.util.Date
添加关联关系。
roo> add field set jpa -fieldName comments -element ~.domain.Comment -class ~.domain.Post -mappedBy post
roo> add field reference jpa -fieldName post -type ~.domain.Post -class ~.domain.Comment
roo> new controller automatic -formBackingObject roodemo.domain.Post -name roode roodemo.web.PostController
Created SRC_MAIN_JAVA/roodemo/web
Created SRC_MAIN_JAVA/roodemo/web/PostController.java
Created SRC_MAIN_JAVA/roodemo/domain/CommentEditor.java
Created SRC_MAIN_JAVA/roodemo/web/PostController_Roo_Controller.aj
Created SRC_MAIN_WEBAPP/images
Created SRC_MAIN_WEBAPP/images/banner-graphic.png
Created SRC_MAIN_WEBAPP/images/springsource-logo.png
Created SRC_MAIN_WEBAPP/images/list.png
Created SRC_MAIN_WEBAPP/images/show.png
Created SRC_MAIN_WEBAPP/images/create.png
Created SRC_MAIN_WEBAPP/images/update.png
Created SRC_MAIN_WEBAPP/images/delete.png
Created SRC_MAIN_WEBAPP/styles
Created SRC_MAIN_WEBAPP/styles/roo.css
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/header.jsp
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/footer.jsp
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/includes.jsp
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/dataAccessFailure.jsp
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/uncaughtException.jsp
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/post
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/post/list.jsp
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/post/show.jsp
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/post/create.jsp
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/post/update.jsp
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/menu.jsp
Managed SRC_MAIN_WEBAPP/WEB-INF/jsp/menu.jsp
Created SRC_MAIN_JAVA/roodemo/domain/CommentEditor_Roo_Editor.aj
roo> new controller automatic -formBackingObject ~.domain.Comment -name ~.web.CommentController
Created SRC_MAIN_JAVA/roodemo/web/CommentController.java
Created SRC_MAIN_JAVA/roodemo/domain/PostEditor.java
Created SRC_MAIN_JAVA/roodemo/web/CommentController_Roo_Controller.aj
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/comment
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/comment/list.jsp
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/comment/show.jsp
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/comment/create.jsp
Created SRC_MAIN_WEBAPP/WEB-INF/jsp/comment/update.jsp
Managed SRC_MAIN_WEBAPP/WEB-INF/jsp/menu.jsp
Created SRC_MAIN_JAVA/roodemo/domain/PostEditor_Roo_Editor.aj