SlideShare a Scribd company logo
Spring Roo 2.0
César Ordiñana & Enrique Ruiz
Spring Roo 2.0 Preview
What is Spring Roo
Current GA release: Spring Roo 1.3.2
What’s new in Spring Roo 2.0
Live demo
What is Spring Roo?
An easy-to-use development tool for quickly building web
applications in the Java programming language
_ _ _ _ _ _ _ _ _ _ _ _
/ _ _  / _ _  / _ _ 
/ / _ / / / / / / / /
/ _ , _ / / _ / / / _ / /
/ _ / | _ |  _ _ _ _ /  _ _ _ _ / 2 . 0 . 0 . M 2
W e l c o m e t o S p r i n g R o o . F o r a s s i s t a n c e p r e s s T A B o r t y p e " h i n t " t h e n h i t E N T E R .
S p r i n g R o o E a s t e r n G r e y U I s t a r t e d a t ' h t t p : / / l o c a l h o s t : 9 1 9 1 / '
r o o >
What Spring Roo is NOT
Spring Roo is not a framework, it is not used in runtime.
Spring Roo engine features
Code generation engine
Programmers code (.java) isolated from generated code
(.aj)
Roo will never overwrite programmers code
Passive and active code generation
Runtime performance not affected by Roo
Why use it?
Higher productivity
Stock-Standard Java and Spring
Bootstraping, maintenance and evolution
Spring Roo 1.x
Applications based on
old technologies
Deprecated
architecture Active
Record
Generated code should
be easier to customize
Extremely simple UI
Basic REST support
Spring Roo 2.0: a new
philosophy
Focused on newer Spring technologies
Create Spring Boot applications
Java-based configuration model
Generate as few code as possible
Easier code customization
Thymeleaf view layer
Demo: New features
Spring IO platform and Boot applications
Global project settings
Conditional command parameters
push-in command
Full support for Spring Data repositories
Improved REST services
New view: Thymeleaf, Bootstrap and JQuery datatables
Create a new project
New > Project > Spring Roo
r o o > p r o j e c t s e t u p - - t o p L e v e l P a c k a g e o r g . s p r i n g i o . t i c k e t
- - p r o j e c t N a m e " S p r i n g I O T i c k e t s " - - j a v a 8 - - p a c k a g i n g J A R
Spring IO and Boot
application
Spring IO and Boot in the pom.xml
Main Boot Application class
Data Access Layer
r o o > j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - -
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - d a t a b a s e N a m e
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - f o r c e
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - h o s t N a m e
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - j n d i D a t a S o u r c e
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - p a s s w o r d
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - p r o f i l e
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - u s e r N a m e
Improved usability
r o o > j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y - -
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y - - f o r c e
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y - - p r o f i l e
r o o > j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y
Domain model
Easily create your JPA domain model with the entity jpa
and field add commands.
r o o > e n t i t y j p a - - c l a s s ~ . m o d e l . T i c k e t
~ . m o d e l . T i c k e t r o o > f i e l d s t r i n g - - f i e l d N a m e n a m e
- - c o m m e n t " T h e t i c k e t ' s n a m e " - - n o t N u l l
- - s i z e M i n 5 - - s i z e M a x 2 0
@ M i n ( 1 )
@ M a x ( 1 0 0 0 )
p r i v a t e I n t e g e r q u a n t i t y ;
~ . m o d e l . T i c k e t r o o > f i e l d n u m b e r - - f i e l d N a m e p r i c e
- - t y p e j a v a . l a n g . I n t e g e r
- - c o m m e n t " T h e s e l l i n g p r i c e "
- - m i n 0 - - m a x 1 0 0 0
Tests
Create a unit test
r o o > t e s t u n i t - - c l a s s ~ . m o d e l . T i c k e t
Customize the code
Overwrite Roo generated methods
TicketTest.java
p u b l i c c l a s s T i c k e t T e s t {
p r i v a t e T i c k e t t i c k e t ;
@ B e f o r e p u b l i c v o i d s e t u p ( ) {
t h i s . t i c k e t = n e w T i c k e t ( ) ;
t h i s . t i c k e t . s e t N a m e ( " E a r l y B i r d " ) ;
t h i s . t i c k e t . s e t Q u a n t i t y ( 7 5 ) ;
t h i s . t i c k e t . s e t P r i c e ( 2 1 9 ) ;
t h i s . t i c k e t . s e t I d ( 1 l ) ;
t h i s . t i c k e t . s e t V e r s i o n ( 1 ) ;
}
}
Customize the code (II)
Create your own methods
TicketTest.java
p u b l i c c l a s s T i c k e t T e s t {
@ T e s t
p u b l i c v o i d c h e c k T o S t r i n g C r e a t e s E x p e c t e d V a l u e ( ) {
a s s e r t E q u a l s ( " E a r l y B i r d , 7 5 , 2 1 9 , 1 , 1 " ,
t i c k e t . t o S t r i n g ( ) ) ;
}
}
Customize the code (III)
New command: push-in
r o o > p u s h - i n - - c l a s s ~ . m o d e l . T i c k e t - - m e t h o d t o S t r i n g
Test.java
p u b l i c S t r i n g t o S t r i n g ( ) {
r e t u r n R e f l e c t i o n T o S t r i n g B u i l d e r . t o S t r i n g ( t h i s ,
T o S t r i n g S t y l e . S I M P L E _ S T Y L E ) ;
}
Project settings
Define the project standards and let Roo control them for
you
r o o > s e t t i n g s a d d - - n a m e s p r i n g . r o o . j p a . r e q u i r e . s c h e m a - o b j e c t - n a m e
- - v a l u e t r u e
r o o > e n t i t y j p a - - c l a s s ~ . m o d e l . C u s t o m e r
Y o u m u s t s p e c i f y o p t i o n ' t a b l e ' f o r t h i s c o m m a n d
More domain model
Ticket → Customer
r o o > s c r i p t - - f i l e ~ / E s c r i t o r i o / c u s t o m e r s . r o o
Repository
r o o > r e p o s i t o r y j p a - - e n t i t y ~ . m o d e l . T i c k e t
r o o > r e p o s i t o r y j p a - - a l l - - p a c k a g e ~ . r e p o s i t o r y
Repository queries
r o o > f i n d e r a d d - - c l a s s ~ . m o d e l . T i c k e t
- - n a m e f i n d B y A v a i l a b l e G r e a t e r T h a n A n d N a m e C o n t a i n i n g O r d e r B y N a m e A s c
Service Layer
r o o > s e r v i c e - - e n t i t y ~ . m o d e l . T i c k e t
- - r e p o s i t o r y ~ . m o d e l . T i c k e t R e p o s i t o r y
- - i n t e r f a c e ~ . s e r v i c e . T i c k e t S e r v i c e
r o o > s e r v i c e - - a l l - - a p i P a c k a g e ~ . s e r v i c e . a p i
- - i m p l P a c k a g e ~ . s e r v i c e . i m p l
Your business logic
r o o > p u s h - i n - - c l a s s ~ . s e r v i c e . i m p l . C u s t o m e r S e r v i c e I m p l - - m e t h o d s a v e
CustomerServiceImpl.java
p r i v a t e f i n a l T i c k e t S e r v i c e t i c k e t S e r v i c e ;
@ A u t o w i r e d
p u b l i c C u s t o m e r S e r v i c e I m p l ( C u s t o m e r R e p o s i t o r y c u s t o m e r R e p o s i t o r y ,
T i c k e t S e r v i c e t i c k e t S e r v i c e ) {
t h i s . c u s t o m e r R e p o s i t o r y = c u s t o m e r R e p o s i t o r y ;
t h i s . t i c k e t S e r v i c e = t i c k e t S e r v i c e ;
}
p r i v a t e v o i d u p d a t e T i c k e t Q u a n t i t y ( C u s t o m e r e n t i t y ) {
i f ( e n t i t y . g e t I d ( ) ! = n u l l ) {
T i c k e t t i c k e t = e n t i t y . g e t T i c k e t ( ) ;
t i c k e t . s e t Q u a n t i t y ( t i c k e t . g e t Q u a n t i t y ( ) - 1 ) ;
t i c k e t S e r v i c e . s a v e ( t i c k e t ) ;
}
}
Your business logic (II)
CustomerServiceImpl.java
@ T r a n s a c t i o n a l ( r e a d O n l y = f a l s e )
p u b l i c C u s t o m e r s a v e ( C u s t o m e r e n t i t y ) {
u p d a t e T i c k e t Q u a n t i t y ( e n t i t y ) ;
r e t u r n c u s t o m e r R e p o s i t o r y . s a v e ( e n t i t y ) ;
}
@ T r a n s a c t i o n a l ( r e a d O n l y = f a l s e )
p u b l i c L i s t < C u s t o m e r > s a v e ( I t e r a b l e < C u s t o m e r > e n t i t i e s ) {
f o r ( C u s t o m e r c u s t o m e r : e n t i t i e s ) {
u p d a t e T i c k e t Q u a n t i t y ( c u s t o m e r ) ;
}
r e t u r n c u s t o m e r R e p o s i t o r y . s a v e ( e n t i t i e s ) ;
}
Presentation Layer
You choose:
Control only → REST Services
Control and View → REST Services + Thymeleaf
Adding web support
w e b m v c s e t u p
REST Services
w e b m v c c o n t r o l l e r - - a l l - - p a c k a g e ~ . w e b
Generating the view
w e b m v c v i e w s e t u p - - t y p e T H Y M E L E A F
Customize the views
w e b m v c t e m p l a t e s s e t u p - - t y p e T H Y M E L E A F
Views and handler
methods
w e b m v c c o n t r o l l e r - - a l l - - p a c k a g e ~ . w e b - - r e s p o n s e T y p e T H Y M E L E A F
Powerful code generation
f i e l d s t r i n g - - f i e l d N a m e d e s c r i p t i o n
Roadmap
DTOs code generation
Non-CRUD REST services
Integration layer
Security layer
Auditing of persistent classes
WebJars integration
UI widgets
Questions?
 http://projects.spring.io/spring-roo/
 https://github.com/spring-projects/spring-roo
 http://stackoverflow.com/questions/tagged/spring-roo
 https://twitter.com/SpringRoo
 http://www.disid.com
Roo it!
Create your Boot applications with Spring Roo 2!

More Related Content

PPTX
[RECAP] Blackholes and Wormholes: Understand and Troubleshoot the “Magic” of ...
PDF
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PDF
From Data to Knowledge
PDF
Metodo de einsten capacidad de transporte
PDF
Pdf check-list-de-llantas compress
PDF
An Introduction to PASETO Tokens
PDF
Josh Griffin - Examples of Work
DOC
11th rep of ese.cmdy .banu
[RECAP] Blackholes and Wormholes: Understand and Troubleshoot the “Magic” of ...
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
From Data to Knowledge
Metodo de einsten capacidad de transporte
Pdf check-list-de-llantas compress
An Introduction to PASETO Tokens
Josh Griffin - Examples of Work
11th rep of ese.cmdy .banu

What's hot (20)

PDF
PROJECT STORYBOARD: Increasing First Run Parts From 60% to 90%
PDF
Company Profile 2014 (Before Rebranding)
PDF
Robotic Process Automation (RPA)_Harvesting a Competitive Advantage
PPTX
Towards Exemplary Moodle Courses at YSJU
PDF
Google clarified structured data's effect on SEO
PDF
AUDIT TRAIL AND TRACEABLILTY OF PRODUCTS
PDF
Analysis by shloka
PDF
Francis cv 27 05-2013
PDF
Understanding Online Consumer Behavior in Fashion E-commerce by the applicati...
PDF
A Comparative Study of Data Management Maturity Models
PDF
military training
PDF
Accounting Class Project - Creating a Private Placement Memorandum
PPTX
A Comparative Study of Data Management Maturity Models
PPT
How IBM API Management use Informix and NoSQL
PPTX
Why the org_matters_shorter.jzt.2018sept25
PPTX
How Consumers use Digital Technology
PDF
Niles West v Glenbrook South 1984
PDF
estimaing assignment
PPT
Hrm hrp 2012
PDF
MICE in Abu Dhabi
PROJECT STORYBOARD: Increasing First Run Parts From 60% to 90%
Company Profile 2014 (Before Rebranding)
Robotic Process Automation (RPA)_Harvesting a Competitive Advantage
Towards Exemplary Moodle Courses at YSJU
Google clarified structured data's effect on SEO
AUDIT TRAIL AND TRACEABLILTY OF PRODUCTS
Analysis by shloka
Francis cv 27 05-2013
Understanding Online Consumer Behavior in Fashion E-commerce by the applicati...
A Comparative Study of Data Management Maturity Models
military training
Accounting Class Project - Creating a Private Placement Memorandum
A Comparative Study of Data Management Maturity Models
How IBM API Management use Informix and NoSQL
Why the org_matters_shorter.jzt.2018sept25
How Consumers use Digital Technology
Niles West v Glenbrook South 1984
estimaing assignment
Hrm hrp 2012
MICE in Abu Dhabi
Ad

Similar to Spring Roo 2.0 Preview at Spring I/O 2016 (20)

KEY
What is the ServiceStack?
KEY
What istheservicestack
KEY
What is the ServiceStack?
KEY
What is the ServiceStack?
PDF
Jlook open api server platform
PDF
Developing a Public API -- at Reversim Summit 2015
PDF
Testing Rich Domain Models
PDF
How NOSQL Paid off for Telenor
KEY
A Walking Tour of (almost) all of Springdom
PDF
Expendables E-AppStore
PDF
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
PDF
Overview of Grails Object Relational Mapping (GORM)
PDF
Questioning the status quo
PDF
Google Developer Days Brazil 2009 - Java Appengine
PDF
Microservices and the Art of Taming the Dependency Hell Monster
KEY
Domain Specific Languages (EclipseCon 2012)
KEY
Appengine Nljug
PDF
Confess_2011 - Rapid Rich Client Development with Spring Roo and GWT
PDF
Better Laziness Through Hypermedia -- Designing a Hypermedia Client
PDF
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
What is the ServiceStack?
What istheservicestack
What is the ServiceStack?
What is the ServiceStack?
Jlook open api server platform
Developing a Public API -- at Reversim Summit 2015
Testing Rich Domain Models
How NOSQL Paid off for Telenor
A Walking Tour of (almost) all of Springdom
Expendables E-AppStore
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
Overview of Grails Object Relational Mapping (GORM)
Questioning the status quo
Google Developer Days Brazil 2009 - Java Appengine
Microservices and the Art of Taming the Dependency Hell Monster
Domain Specific Languages (EclipseCon 2012)
Appengine Nljug
Confess_2011 - Rapid Rich Client Development with Spring Roo and GWT
Better Laziness Through Hypermedia -- Designing a Hypermedia Client
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Ad

Recently uploaded (20)

PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
System and Network Administration Chapter 2
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
L1 - Introduction to python Backend.pptx
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Transform Your Business with a Software ERP System
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
CHAPTER 2 - PM Management and IT Context
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
System and Network Administration Chapter 2
Internet Downloader Manager (IDM) Crack 6.42 Build 41
L1 - Introduction to python Backend.pptx
wealthsignaloriginal-com-DS-text-... (1).pdf
Design an Analysis of Algorithms II-SECS-1021-03
2025 Textile ERP Trends: SAP, Odoo & Oracle
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Odoo POS Development Services by CandidRoot Solutions
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Transform Your Business with a Software ERP System
Navsoft: AI-Powered Business Solutions & Custom Software Development
Which alternative to Crystal Reports is best for small or large businesses.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Understanding Forklifts - TECH EHS Solution
Reimagine Home Health with the Power of Agentic AI​
CHAPTER 2 - PM Management and IT Context

Spring Roo 2.0 Preview at Spring I/O 2016

  • 1. Spring Roo 2.0 César Ordiñana & Enrique Ruiz
  • 2. Spring Roo 2.0 Preview What is Spring Roo Current GA release: Spring Roo 1.3.2 What’s new in Spring Roo 2.0 Live demo
  • 3. What is Spring Roo? An easy-to-use development tool for quickly building web applications in the Java programming language _ _ _ _ _ _ _ _ _ _ _ _ / _ _ / _ _ / _ _ / / _ / / / / / / / / / _ , _ / / _ / / / _ / / / _ / | _ | _ _ _ _ / _ _ _ _ / 2 . 0 . 0 . M 2 W e l c o m e t o S p r i n g R o o . F o r a s s i s t a n c e p r e s s T A B o r t y p e " h i n t " t h e n h i t E N T E R . S p r i n g R o o E a s t e r n G r e y U I s t a r t e d a t ' h t t p : / / l o c a l h o s t : 9 1 9 1 / ' r o o >
  • 4. What Spring Roo is NOT Spring Roo is not a framework, it is not used in runtime.
  • 5. Spring Roo engine features Code generation engine Programmers code (.java) isolated from generated code (.aj) Roo will never overwrite programmers code Passive and active code generation Runtime performance not affected by Roo
  • 6. Why use it? Higher productivity Stock-Standard Java and Spring Bootstraping, maintenance and evolution
  • 7. Spring Roo 1.x Applications based on old technologies Deprecated architecture Active Record Generated code should be easier to customize Extremely simple UI Basic REST support
  • 8. Spring Roo 2.0: a new philosophy Focused on newer Spring technologies Create Spring Boot applications Java-based configuration model Generate as few code as possible Easier code customization Thymeleaf view layer
  • 9. Demo: New features Spring IO platform and Boot applications Global project settings Conditional command parameters push-in command Full support for Spring Data repositories Improved REST services New view: Thymeleaf, Bootstrap and JQuery datatables
  • 10. Create a new project New > Project > Spring Roo r o o > p r o j e c t s e t u p - - t o p L e v e l P a c k a g e o r g . s p r i n g i o . t i c k e t - - p r o j e c t N a m e " S p r i n g I O T i c k e t s " - - j a v a 8 - - p a c k a g i n g J A R
  • 11. Spring IO and Boot application Spring IO and Boot in the pom.xml Main Boot Application class
  • 12. Data Access Layer r o o > j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - d a t a b a s e N a m e j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - f o r c e j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - h o s t N a m e j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - j n d i D a t a S o u r c e j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - p a s s w o r d j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - p r o f i l e j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - u s e r N a m e
  • 13. Improved usability r o o > j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y - - j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y - - f o r c e j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y - - p r o f i l e r o o > j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y
  • 14. Domain model Easily create your JPA domain model with the entity jpa and field add commands. r o o > e n t i t y j p a - - c l a s s ~ . m o d e l . T i c k e t ~ . m o d e l . T i c k e t r o o > f i e l d s t r i n g - - f i e l d N a m e n a m e - - c o m m e n t " T h e t i c k e t ' s n a m e " - - n o t N u l l - - s i z e M i n 5 - - s i z e M a x 2 0 @ M i n ( 1 ) @ M a x ( 1 0 0 0 ) p r i v a t e I n t e g e r q u a n t i t y ; ~ . m o d e l . T i c k e t r o o > f i e l d n u m b e r - - f i e l d N a m e p r i c e - - t y p e j a v a . l a n g . I n t e g e r - - c o m m e n t " T h e s e l l i n g p r i c e " - - m i n 0 - - m a x 1 0 0 0
  • 15. Tests Create a unit test r o o > t e s t u n i t - - c l a s s ~ . m o d e l . T i c k e t
  • 16. Customize the code Overwrite Roo generated methods TicketTest.java p u b l i c c l a s s T i c k e t T e s t { p r i v a t e T i c k e t t i c k e t ; @ B e f o r e p u b l i c v o i d s e t u p ( ) { t h i s . t i c k e t = n e w T i c k e t ( ) ; t h i s . t i c k e t . s e t N a m e ( " E a r l y B i r d " ) ; t h i s . t i c k e t . s e t Q u a n t i t y ( 7 5 ) ; t h i s . t i c k e t . s e t P r i c e ( 2 1 9 ) ; t h i s . t i c k e t . s e t I d ( 1 l ) ; t h i s . t i c k e t . s e t V e r s i o n ( 1 ) ; } }
  • 17. Customize the code (II) Create your own methods TicketTest.java p u b l i c c l a s s T i c k e t T e s t { @ T e s t p u b l i c v o i d c h e c k T o S t r i n g C r e a t e s E x p e c t e d V a l u e ( ) { a s s e r t E q u a l s ( " E a r l y B i r d , 7 5 , 2 1 9 , 1 , 1 " , t i c k e t . t o S t r i n g ( ) ) ; } }
  • 18. Customize the code (III) New command: push-in r o o > p u s h - i n - - c l a s s ~ . m o d e l . T i c k e t - - m e t h o d t o S t r i n g Test.java p u b l i c S t r i n g t o S t r i n g ( ) { r e t u r n R e f l e c t i o n T o S t r i n g B u i l d e r . t o S t r i n g ( t h i s , T o S t r i n g S t y l e . S I M P L E _ S T Y L E ) ; }
  • 19. Project settings Define the project standards and let Roo control them for you r o o > s e t t i n g s a d d - - n a m e s p r i n g . r o o . j p a . r e q u i r e . s c h e m a - o b j e c t - n a m e - - v a l u e t r u e r o o > e n t i t y j p a - - c l a s s ~ . m o d e l . C u s t o m e r Y o u m u s t s p e c i f y o p t i o n ' t a b l e ' f o r t h i s c o m m a n d
  • 20. More domain model Ticket → Customer r o o > s c r i p t - - f i l e ~ / E s c r i t o r i o / c u s t o m e r s . r o o
  • 21. Repository r o o > r e p o s i t o r y j p a - - e n t i t y ~ . m o d e l . T i c k e t r o o > r e p o s i t o r y j p a - - a l l - - p a c k a g e ~ . r e p o s i t o r y
  • 22. Repository queries r o o > f i n d e r a d d - - c l a s s ~ . m o d e l . T i c k e t - - n a m e f i n d B y A v a i l a b l e G r e a t e r T h a n A n d N a m e C o n t a i n i n g O r d e r B y N a m e A s c
  • 23. Service Layer r o o > s e r v i c e - - e n t i t y ~ . m o d e l . T i c k e t - - r e p o s i t o r y ~ . m o d e l . T i c k e t R e p o s i t o r y - - i n t e r f a c e ~ . s e r v i c e . T i c k e t S e r v i c e r o o > s e r v i c e - - a l l - - a p i P a c k a g e ~ . s e r v i c e . a p i - - i m p l P a c k a g e ~ . s e r v i c e . i m p l
  • 24. Your business logic r o o > p u s h - i n - - c l a s s ~ . s e r v i c e . i m p l . C u s t o m e r S e r v i c e I m p l - - m e t h o d s a v e CustomerServiceImpl.java p r i v a t e f i n a l T i c k e t S e r v i c e t i c k e t S e r v i c e ; @ A u t o w i r e d p u b l i c C u s t o m e r S e r v i c e I m p l ( C u s t o m e r R e p o s i t o r y c u s t o m e r R e p o s i t o r y , T i c k e t S e r v i c e t i c k e t S e r v i c e ) { t h i s . c u s t o m e r R e p o s i t o r y = c u s t o m e r R e p o s i t o r y ; t h i s . t i c k e t S e r v i c e = t i c k e t S e r v i c e ; } p r i v a t e v o i d u p d a t e T i c k e t Q u a n t i t y ( C u s t o m e r e n t i t y ) { i f ( e n t i t y . g e t I d ( ) ! = n u l l ) { T i c k e t t i c k e t = e n t i t y . g e t T i c k e t ( ) ; t i c k e t . s e t Q u a n t i t y ( t i c k e t . g e t Q u a n t i t y ( ) - 1 ) ; t i c k e t S e r v i c e . s a v e ( t i c k e t ) ; } }
  • 25. Your business logic (II) CustomerServiceImpl.java @ T r a n s a c t i o n a l ( r e a d O n l y = f a l s e ) p u b l i c C u s t o m e r s a v e ( C u s t o m e r e n t i t y ) { u p d a t e T i c k e t Q u a n t i t y ( e n t i t y ) ; r e t u r n c u s t o m e r R e p o s i t o r y . s a v e ( e n t i t y ) ; } @ T r a n s a c t i o n a l ( r e a d O n l y = f a l s e ) p u b l i c L i s t < C u s t o m e r > s a v e ( I t e r a b l e < C u s t o m e r > e n t i t i e s ) { f o r ( C u s t o m e r c u s t o m e r : e n t i t i e s ) { u p d a t e T i c k e t Q u a n t i t y ( c u s t o m e r ) ; } r e t u r n c u s t o m e r R e p o s i t o r y . s a v e ( e n t i t i e s ) ; }
  • 26. Presentation Layer You choose: Control only → REST Services Control and View → REST Services + Thymeleaf
  • 27. Adding web support w e b m v c s e t u p
  • 28. REST Services w e b m v c c o n t r o l l e r - - a l l - - p a c k a g e ~ . w e b
  • 29. Generating the view w e b m v c v i e w s e t u p - - t y p e T H Y M E L E A F
  • 30. Customize the views w e b m v c t e m p l a t e s s e t u p - - t y p e T H Y M E L E A F
  • 31. Views and handler methods w e b m v c c o n t r o l l e r - - a l l - - p a c k a g e ~ . w e b - - r e s p o n s e T y p e T H Y M E L E A F
  • 32. Powerful code generation f i e l d s t r i n g - - f i e l d N a m e d e s c r i p t i o n
  • 33. Roadmap DTOs code generation Non-CRUD REST services Integration layer Security layer Auditing of persistent classes WebJars integration UI widgets
  • 34. Questions?  http://projects.spring.io/spring-roo/  https://github.com/spring-projects/spring-roo  http://stackoverflow.com/questions/tagged/spring-roo  https://twitter.com/SpringRoo  http://www.disid.com
  • 35. Roo it! Create your Boot applications with Spring Roo 2!