- 浏览: 2542671 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Spring Roo Docs(2)Pizza shop sample and backup
2.3. Tutorial Application Details
We will create a web site for a Pizza Shop. A pizza is composed of a base and one or more toppings.
Domain Models:
PizzaOrder
name:String
address: String
total:double
deliveryDate:Date
pizzas:Set<Pizza>
Pizza
name:String
price:double
toppings:Set<Topping>
base:Base
Topping
name:String
Base
name:String
2.4 Step 1: Starting a Typical Project
>mkdir pizza
>cd pizza
roo>project --topLevelPackage com.sillycat.pizzashop
roo>jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
Hibernate is the object-relational mapping(ORM) provider, it is one of three ORM providers which Roo currently offers.
Command to install a local file to our local maven repository
>mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.2 -Dpackaging=jar -Dfile=/path/to/file
2.5. Step2: Creating Entities and Fields
roo>entity jpa --class com.sillycat.pizzashop.models.Topping --testAutomatically
roo>field string --fieldName name --notNull --sizeMin 2
roo>entity jpa --class ~.models.Base --testAutomatically
roo>field string name --notNull --sizeMin 2
roo>entity jpa --class ~.models.Pizza --testAutomatically
roo>field string --fieldName name --notNull --sizeMin 2
roo>field number --fieldName price --type java.lang.Float
Try to create many-to-many relationships.
roo>field set --fieldName toppings --type ~.models.Topping
Try to create many-to-one relationships.
roo>field reference --fieldName base --type ~.models.Base
Create the PizzaOrder object.
2.6. Step 3: Integeration Tests
You can create integration tests alone with command "test integration", and run tests with command "perform tests".
roo>perform tests
2.7. Step 4: Using Your IDE
roo>perform eclipse
2.8. Step 5: Creating A Web Tier
roo>web mvc setup
roo>web mvc all --package ~.web
This command will scan the Pizza Shop project for any domain entities and scaffold a Spring MVC controller for each entity detected.
src/main/webapp folder, this folder includes graphics, cascading style sheets, Java Server pages, Tiles configurations and more.
2.9. Step 6: Loading the Web Server
>mvn tomcat:run
>mvn jetty:run
Visit http://localhost:8080/pizzashop to verify.
2.10. Securing the Application
roo>security setup
We need to secure the views for Topping, Base, and Pizza resources, so we change the configuration file applicationContext-security.xml file.
<intercept-url pattern="/pizzas/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/toppings/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/bases/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/resources/**" access="permitAll" />
<intercept-url pattern="/static/**" access="permitAll" />
<intercept-url pattern="/**" access="permitAll" />
<authentication-provider>
<user-service>
<user name="admin" password="admin" authorities="ROLE_ADMIN" />
<user name="user" password="user" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
Next step, I use spring security JSP tag library to restrict access to the relevant menu items in the menu.jspx
<div xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:sec="http://www.springframework.org/security/tags"
xmlns:menu="urn:jsptagdir:/WEB-INF/tags/menu" id="menu" version="2.0">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<sec:authorize ifAllGranted="ROLE_ADMIN">
...snip...
</sec:authorize>
Leave the pizza order view visible to the public. Obviously the delete and update actions for pizza order view are not desirable. So I change the PizzaOrderController.java source:
@RooWebScaffold(path = "pizzaorders", formBackingObject = PizzaOrder.class, delete = false, update = false)
Login this page to verify http://localhost:8080/pizzashop/login.
2.11. Customizing the Look & Feel of the Web UI
/styles style sheets(CSS)
/images graphics
/WEB-INF/classes/*.properties theme configurations
/WEB-INF/config/*.xml Web-related Spring application contexts
/WEB-INF/i18n/*.properties internationalization message files
/WEB-INF/layouts/layout.jspx Tiles definition for master layout
/WEB-INF/tags/*.tagx Tag libraries(paination, language, etc)
/WEB-INF/views/**/* Tiles and other view artifacts
2.12. Selenium Tests
roo>selenium test --controller ~.web.ToppingController
roo>selenium test --controller ~.web.BaseController
...snip...
These commands will generate the selenium test codes and locate in src/main/webapp/selenium foler.
>mvn selenium:selenese
2.13. Backups and Deployment
roo>backup
This command will backup current workspace with all sources, log files and the script log file(excluding the target directory)
references:
books:
spring-roo-docs.pdf
2.3. Tutorial Application Details
We will create a web site for a Pizza Shop. A pizza is composed of a base and one or more toppings.
Domain Models:
PizzaOrder
name:String
address: String
total:double
deliveryDate:Date
pizzas:Set<Pizza>
Pizza
name:String
price:double
toppings:Set<Topping>
base:Base
Topping
name:String
Base
name:String
2.4 Step 1: Starting a Typical Project
>mkdir pizza
>cd pizza
roo>project --topLevelPackage com.sillycat.pizzashop
roo>jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
Hibernate is the object-relational mapping(ORM) provider, it is one of three ORM providers which Roo currently offers.
Command to install a local file to our local maven repository
>mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.2 -Dpackaging=jar -Dfile=/path/to/file
2.5. Step2: Creating Entities and Fields
roo>entity jpa --class com.sillycat.pizzashop.models.Topping --testAutomatically
roo>field string --fieldName name --notNull --sizeMin 2
roo>entity jpa --class ~.models.Base --testAutomatically
roo>field string name --notNull --sizeMin 2
roo>entity jpa --class ~.models.Pizza --testAutomatically
roo>field string --fieldName name --notNull --sizeMin 2
roo>field number --fieldName price --type java.lang.Float
Try to create many-to-many relationships.
roo>field set --fieldName toppings --type ~.models.Topping
Try to create many-to-one relationships.
roo>field reference --fieldName base --type ~.models.Base
Create the PizzaOrder object.
2.6. Step 3: Integeration Tests
You can create integration tests alone with command "test integration", and run tests with command "perform tests".
roo>perform tests
2.7. Step 4: Using Your IDE
roo>perform eclipse
2.8. Step 5: Creating A Web Tier
roo>web mvc setup
roo>web mvc all --package ~.web
This command will scan the Pizza Shop project for any domain entities and scaffold a Spring MVC controller for each entity detected.
src/main/webapp folder, this folder includes graphics, cascading style sheets, Java Server pages, Tiles configurations and more.
2.9. Step 6: Loading the Web Server
>mvn tomcat:run
>mvn jetty:run
Visit http://localhost:8080/pizzashop to verify.
2.10. Securing the Application
roo>security setup
We need to secure the views for Topping, Base, and Pizza resources, so we change the configuration file applicationContext-security.xml file.
<intercept-url pattern="/pizzas/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/toppings/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/bases/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/resources/**" access="permitAll" />
<intercept-url pattern="/static/**" access="permitAll" />
<intercept-url pattern="/**" access="permitAll" />
<authentication-provider>
<user-service>
<user name="admin" password="admin" authorities="ROLE_ADMIN" />
<user name="user" password="user" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
Next step, I use spring security JSP tag library to restrict access to the relevant menu items in the menu.jspx
<div xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:sec="http://www.springframework.org/security/tags"
xmlns:menu="urn:jsptagdir:/WEB-INF/tags/menu" id="menu" version="2.0">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<sec:authorize ifAllGranted="ROLE_ADMIN">
...snip...
</sec:authorize>
Leave the pizza order view visible to the public. Obviously the delete and update actions for pizza order view are not desirable. So I change the PizzaOrderController.java source:
@RooWebScaffold(path = "pizzaorders", formBackingObject = PizzaOrder.class, delete = false, update = false)
Login this page to verify http://localhost:8080/pizzashop/login.
2.11. Customizing the Look & Feel of the Web UI
/styles style sheets(CSS)
/images graphics
/WEB-INF/classes/*.properties theme configurations
/WEB-INF/config/*.xml Web-related Spring application contexts
/WEB-INF/i18n/*.properties internationalization message files
/WEB-INF/layouts/layout.jspx Tiles definition for master layout
/WEB-INF/tags/*.tagx Tag libraries(paination, language, etc)
/WEB-INF/views/**/* Tiles and other view artifacts
2.12. Selenium Tests
roo>selenium test --controller ~.web.ToppingController
roo>selenium test --controller ~.web.BaseController
...snip...
These commands will generate the selenium test codes and locate in src/main/webapp/selenium foler.
>mvn selenium:selenese
2.13. Backups and Deployment
roo>backup
This command will backup current workspace with all sources, log files and the script log file(excluding the target directory)
references:
books:
spring-roo-docs.pdf
发表评论
-
NodeJS12 and Zlib
2020-04-01 07:44 468NodeJS12 and Zlib It works as ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 330Traefik 2020(1)Introduction and ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 428Private Registry 2020(1)No auth ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 377Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 468NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 414Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 332Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 243GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 445GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 321GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 307Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 310Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 286Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 303Serverless with NodeJS and Tenc ... -
NodeJS MySQL Library and npmjs
2020-02-07 06:21 282NodeJS MySQL Library and npmjs ... -
Python Library 2019(1)requests and aiohttp
2019-12-18 01:12 257Python Library 2019(1)requests ... -
NodeJS Installation 2019
2019-10-20 02:57 565NodeJS Installation 2019 Insta ... -
Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts
2019-10-18 10:57 257Monitor Tool 2019(2)Monit on Mu ... -
Sqlite Database 2019(1)Sqlite3 Installation and Docker phpsqliteadmin
2019-09-05 11:24 362Sqlite Database 2019(1)Sqlite3 ... -
Supervisor 2019(2)Ubuntu and Multiple Services
2019-08-19 10:53 366Supervisor 2019(2)Ubuntu and Mu ...
相关推荐
【os-springroo2-sample_code】项目是一个关于Spring Roo的示例代码库,它展示了如何使用Spring Roo框架来快速开发应用程序。Spring Roo是Spring框架的一部分,它提供了一种简化和加速Java应用开发的方式,通过自动...
### SpringRoo-ReferenceDocumentation 1.2.5.RELEASE 关键知识点解析 #### 一、SpringRoo简介 **1.1 SpringRoo是什么?** SpringRoo是一款旨在提高开发效率的工具,它能够帮助开发者快速搭建基于Spring框架的...
Spring Roo是一个轻量级的Java开发工具,用于快速搭建Spring应用。它采用了一种新的方式来开发Spring应用程序,即通过命令行而非传统的集成开发环境(IDE)。Spring Roo提供了一系列命令,使得开发者可以轻松地创建...
### Spring Roo 使用文档知识点概述 #### 一、Spring Roo 简介 - **Spring Roo** 是一个基于命令行的工具,旨在简化 Spring 应用程序的开发过程。 - **功能定位**:它通过提供一系列预定义的命令来加速应用程序的...
**Spring Roo 简介,第 4 部分: 用 Spring Roo 和 Cloud Foundry 在云中快速开发应用程序** 在本篇文章中,我们将深入探讨 Spring Roo 的使用,以及如何结合 Cloud Foundry 进行云端应用开发。Spring Roo 是一个...
Spring Roo是一个用于快速开发Java应用程序的框架,它结合了Spring生态系统的强大功能,尤其是对Spring MVC、Spring Security、Spring Tiles、Spring Web Flow以及Spring测试支持等方面。 Spring Roo利用了一种...
**Spring ROO详解** Spring ROO是Spring框架下的一个快速开发工具,旨在简化Java应用程序的构建过程,尤其针对企业级应用。它通过自动化任务、代码生成以及最佳实践的应用,极大地提高了开发效率。Spring ROO的核心...
**Spring Roo命令文档** Spring Roo是Spring框架的一部分,它提供了一种快速开发工具,帮助开发者在Java应用中创建和管理代码。Roo通过自动化过程,简化了常见的开发任务,如设置项目结构、创建实体类、生成数据库...
Spring Roo是Spring框架家族中的一个创新工具,旨在简化Java应用程序的开发过程,特别是企业级应用。它基于Spring的模块化架构,提供了一种快速开发、自动化代码生成和最佳实践集成的解决方案。Spring Roo 1.1.3是该...
Spring Roo是Spring框架家族中的一个开源工具,旨在简化Java应用程序的开发过程,特别是Spring MVC和Spring Data应用。这个"spring-roo-2.0.0.RC1.zip"压缩包包含的是Spring Roo的2.0.0 Release Candidate 1版本,这...
Spring Roo是Spring框架家族中的一个开发工具,它旨在加速Java应用程序的开发过程,特别是通过提供命令行接口和集成开发环境(IDE)插件来简化常见的编程任务。标题"spring-roo-1.1.5.RELEASE"指的是Spring Roo的一...
### SpringRoo官方文档知识点概览 #### 一、概述 SpringRoo 是一款由 Pivotal Software(现为 VMware 的一部分)开发的快速应用开发工具。它旨在帮助开发者简化基于Spring框架的应用程序构建过程。SpringRoo 通过...
Spring Roo是Spring框架家族中的一个工具,用于加速Java开发,特别是企业级应用的构建。它通过命令行界面或集成开发环境(IDE)插件提供了一种快速开发的方式,可以帮助开发者生成代码、设置依赖和配置,使得开发...
2. 添加依赖:SpringRoo允许使用`roo add dependency`命令快速添加所需的Spring或其他库的依赖。 3. 生成代码:SpringRoo支持自动生成领域模型类、DAO、Service和Controller代码。只需指定实体类的属性,Roo会自动...
2. **代码生成**:Spring Roo可以自动生成常见的Java类、Maven或Gradle构建文件、Spring配置文件、JPA实体、DAO、服务和控制器。这极大地减少了手动编码的时间,使开发者能更快地专注于业务逻辑。 3. **快速应用...
Spring Roo是Spring Framework的一个附加工具,它为Java开发者提供了一个快速开发平台,旨在简化和加速应用程序的构建过程。"spring-roo-1.1.0.M1.zip_54587.m1_M1 ssh_Spring Roo download_spri"这个标题暗示了这是...
### Spring Roo - 高效开发框架的深度解析 #### 引言:Spring Roo与生产力的飞跃 Spring Roo作为Spring框架的扩展,旨在显著提升开发者在构建企业级Java应用时的效率。它通过自动化代码生成、简化项目搭建以及提供...
2. **导航到 Spring Roo 源代码目录**。 3. **执行构建命令**:在终端中运行 `mvn clean install` 命令以构建 Spring Roo。这个过程可能需要几分钟的时间。 4. **验证安装**:构建完成后,可以通过运行 `roo` 命令来...
### Spring Roo Action: 加速开发流程的利器 #### 引言 随着软件开发技术的不断发展,开发者们一直在寻求更高效、更便捷的方式来构建高质量的应用程序。Spring Roo 正是为了解决这一需求而诞生的。它是一种快速应用...