Grails 101


Published on

Grails Introduction Slides

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Grails 101

  1. 1. Grails 101 Lim Chee Kin
  2. 2. About Me● Moderator of the Malaysia Groovy and Grails User Group● Involved in Grails development since version 0.6 and developed 15 Grails plugins to date● 10+ years experience in software development and solution consulting for Java EE platform● Experience spans across various industries, including retail sector, telecommunication, heath care and financial services industry.● Experienced in many frameworks and web technologies, including Java EE, SpringFramework, Hibernate, Groovy, Grails Framework, Web Services, JQuery, JQuery UI
  3. 3. Why Grails●●● To practice agile development process you need an agile framework.
  4. 4. Inside Grails● Seamless integration of ...● Groovy ● Tomcat● Java ● Ant● SpringFramework ● Maven● Hibernate ● Log4J● Java EE ● H2 Database● Sitemesh ● Quartz● JQuery ● ... many more
  5. 5. Best Practices Support● Convention over Configuration standard directory structure● Dependency Injection SpringFramework● Model domain class View GSP Controller groovy class● Test Automation JUnit, Spock● Modularization plugin system● Code Generation scaffolding● Fast Development Cycle dynamic reloading
  6. 6. Running Grails App in 5 minutes● Step 1: grails create-app addressbook●● Step 2: grails create-domain-class Person●● Step 3: grails generate-all Person●● Step 4: grails run-app
  7. 7. Step 1: grails create-app addressbook● Created Grails Application at /opt/dev/ws/addressbook
  8. 8. Step 1: grails create-app addressbook /addressbook●● grails-app/conf/ --> location of configuration artifacts● grails-app/conf/hibernate --> optional hibernate config● grails-app/conf/spring --> optional spring config● grails-app/controllers/ --> location of controller artifacts● grails-app/domain/ --> location of domain classes● grails-app/i18n/ --> location of message bundles for i18n● grails-app/services/ --> location of services● grails-app/taglib/ --> location of tag libraries● grails-app/utils/ --> location of grails specific utility classes● grails-app/views/ --> location of views● grails-app/views/layouts --> location of layouts● lib/ --> jar files not available via installed plugins● scripts/ --> scripts● src/groovy --> optional; location for Groovy source files (of types other than those in grails-app/*)● src/java --> optional; location for Java source files● test/ --> test classes● web-app/ --> css, images, etc, etc, etc.
  9. 9. Step 2: grails create-domain-class Person● Created file grails-app/domain/addressbook/Person.groovy Created file test/unit/addressbook/PersonTests.groovy●● class Person {● String firstName● String lastName● Date dateOfBirth● Integer age●● static constraints = {● firstName(nullable:true, maxSize:60)● lastName(nullable:true, maxSize:30)● dateOfBirth(nullable:true, maxSize:10)● age(nullable:true)● }● }
  10. 10. Step 3: grails generate-all Person● Finished generation for domain class addressbook.Person
  11. 11. Step 4: grails run-appServer running. Browse to http://localhost:8080/addressbook
  12. 12. Step 4: grails run-app
  13. 13. Step 4: grails run-app
  14. 14. My Open Source Grails Plugins● I contributed 15 Grails plugins out of 826 (13 Aug 2012), including:● Grails Activiti Plugin●● Grails Form Builder Plugin●● JQuery Validation UI Plugin●● Mahout Recommender Plugin●● Find out more at
  15. 15. Q&A