Groovy On Grails setup on windows
Groovy On Grails Configuration for Windows Environment
=> Download Java SE Development Kit (JDK 1.4.x or more ) installer for windows
( http://java.sun.com/javase/downloads/index.jsp)
=> Download Latest Version Groovy 1.5.x( http://groovy.codehaus.org) Binary Zip.
=> Download Latest Version Grails 1.1.x(http://www.grails.org) Binary Zip.
=> Install JDK
=> Unzip Binary in any folder, in my end it unzip on c:\installation.
Eg. c:\installation\groovy1.5.x
c:\installation\grails1.1.x
c:\Program Files\Java\ jdk1.5.9
=>Set Environment variable for Groovy on Grails and Java
Right Click on My Computer ->Properties->Advanced tab->Environment variable
Create User variable
Variable Value
JAVA_HOME c:\Program Files\Java\jdk1.5.9
GROOVY_HOME c:\installation\groovy1.5.x
GRAILS_HOME c:\installation\grails1.1.x
path %JAVA_HOME%\bin;%GROOVY_HOME%\bin;%GRAILS_HOME% \bin;%GRAILS_HOME%\ant\bin
=> Testing Configuration
Check with START->run->cmd . you will get the command Prompt.
Run c:\>javac : you will get the java option that means
Run c:\>grails help : you will get Grails command line artifacts for creating grails application it classes etc..
Examples:
grails dev run-app
grails create-app books
Available Targets (type grails help 'target-name' for more info):
grails bootstrap
grails bug-report
grails clean
grails compile
grails console
grails create-app
grails create-controller
grails create-domain-class
grails create-filters
grails create-integration-test
grails create-plugin
grails create-script
grails create-service
grails create-tag-lib
grails create-unit-test
grails doc
grails generate-all
grails generate-controller
grails generate-views
grails help
grails init
grails install-plugin
grails install-templates
grails list-plugins
grails package
grails package-plugin
grails plugin-info
grails release-plugin
grails run-app
grails run-war
grails schema-export
grails set-proxy
grails set-version
grails shell
grails stats
grails test-app
grails uninstall-plugin
grails upgrade
grails war
=> Grails Sample Applications using Scaffold.
Goto command prompt
c:\> grails create-app EMP
c:\>cd EMP
u ll see the Folder structure is created for grails project , it follows MVC design pattern,
so u can manage your code properly like we can separate thing, all presentation logic we keep in grails-app/view folder , we can add model class in grails-app/domain folder, controller class added to perform actions on http request/response keep in grails-app/Controller folder, grails provide good command line artifact to perform this action ...
u can simply run c:\EMP> grails run-app
and http://localhost:8080/EMP u will see the index page of create application..
added a domain class
c:\EMP> grails create-domain-class User ->this command is create a User Class .
u can Edit this grails-app/domain/User.groovy class , add attribute
class User{
String userName
String password
static constraints = {}
}
similarly create Controller for User.Class
c:\EMP> grails create-controller User
u can Edit this grails-app/controller/UserController.groovy class ,
class UserController {
def scaffold = User
}
now save this classes and run application
c:\EMP> grails run-app
hit http://localhost:8080/EMP on browser u will see the index page with user controller action link, u can now easily perform Add/Modify/Delete/List feature
Comments