- Download grails latest version from http://grails.org/
- Extract it to specific location (e.g. C:\grails)
- Create environment variable GRAILS_HOME
- Add %GRAILS_HOME%\bin into the %Path% variable (for windows)
Create Demo Project
- Go to your workspace or directory where you want to create project.
- Create grails project using below command
grails create-app BookStore
- Now we need to create doamins Book and Publisher
grails create-domain-class com.hardik4u.Publisher
grails create-domain-class com.hardik4u.Book
- Its time to edit both domain groovy classes
- Go to <Project_workspace>\BookStore\grails-app\domain\com\hardik4u and edit as below
Book.groovy
package com.hardik4uPublisher.groovy
import java.util.*;
class Book {
int bookId;
String bookName;
Publisher publisher;
Date publishDate;
}
package com.hardik4u
class Publisher {
int publisherId;
String publisherName;
}
- Now we need to generate controllers,gsp(grails server pages) files from the domain, so type below command
grails-generate-all
it will ask for domain class name, enter com.hardik4u.Publisher
Do above step for com.hardik4u.Book
Now time to up the application using inbuilt jetty
Type the below command from the project home directory
grails run-app
- Hit the URL http://localhost:8080/BookStore in the browser
- Click on the com.hardik4u.BookController
- It will redirect you to the book list page,add some dummy data in Book and Publisher.
Cheers :)
No comments:
Post a Comment