Table of Contents
설치하기#
다운로드 #
다운로드 페이지인 http://www.grails.org/Download
설정하기#
Linux의 경우 .cshrc나 .bash_profile, Windows의 경우 환경변수에 GRAILS_HOME을 압축을 푼 디렉터리로 셋팅한다.기본 애플리케이션 작성하기#
프로젝트 생성하기#
grails create-app
명령창에서 "Application name not specified. Please enter:" 와 같은 메시지로 프로젝트명을 요구할때 프로젝트명을 셋팅하면 가장 기본적인 구조를 만들어진다.
D:\temp>grails create-app Welcome to Grails 1.0.4 - http://grails.org/ Licensed under Apache Standard License 2.0 Grails home is set to: D:\grails-1.0.4 Base Directory: D:\temp Note: No plugin scripts found Running script D:\grails-1.0.4\scripts\CreateApp.groovy Environment set to development Application name not specified. Please enter: test [mkdir] Created dir: D:\temp\test\src [mkdir] Created dir: D:\temp\test\src\java [mkdir] Created dir: D:\temp\test\src\groovy [mkdir] Created dir: D:\temp\test\grails-app [mkdir] Created dir: D:\temp\test\grails-app\controllers [mkdir] Created dir: D:\temp\test\grails-app\services [mkdir] Created dir: D:\temp\test\grails-app\domain [mkdir] Created dir: D:\temp\test\grails-app\taglib [mkdir] Created dir: D:\temp\test\grails-app\utils [mkdir] Created dir: D:\temp\test\grails-app\views [mkdir] Created dir: D:\temp\test\grails-app\views\layouts [mkdir] Created dir: D:\temp\test\grails-app\i18n [mkdir] Created dir: D:\temp\test\grails-app\conf [mkdir] Created dir: D:\temp\test\test [mkdir] Created dir: D:\temp\test\test\unit [mkdir] Created dir: D:\temp\test\test\integration [mkdir] Created dir: D:\temp\test\scripts [mkdir] Created dir: D:\temp\test\web-app [mkdir] Created dir: D:\temp\test\web-app\js [mkdir] Created dir: D:\temp\test\web-app\css [mkdir] Created dir: D:\temp\test\web-app\images [mkdir] Created dir: D:\temp\test\web-app\META-INF [mkdir] Created dir: D:\temp\test\lib [mkdir] Created dir: D:\temp\test\grails-app\conf\spring [mkdir] Created dir: D:\temp\test\grails-app\conf\hibernate [propertyfile] Creating new property file: D:\temp\test\application.properties [copy] Copying 2 files to D:\temp\test [copy] Copied 1 empty directory to 1 empty directory under D:\temp\test [copy] Copying 2 files to D:\temp\test\web-app\WEB-INF [copy] Copying 5 files to D:\temp\test\web-app\WEB-INF\tld [copy] Copying 28 files to D:\temp\test\web-app [copy] Copying 18 files to D:\temp\test\grails-app [copy] Copying 1 file to D:\temp\test [copy] Copying 1 file to D:\temp\test [copy] Copying 1 file to D:\temp\test [copy] Copying 1 file to D:\temp\test [propertyfile] Updating property file: D:\temp\test\application.properties Created Grails Application at D:\temp/test
디렉터리 구조#
![]() |
구조를 보면 알겠지만 이미 grails는 Spring프레임워크와 연동되도록 구조가 잡혀있다. 그외 hibernate를 위한 기본 구조도 함께 가지고 있다.
![]() |
그리고 구조 자체는 eclipse프로젝트로 등록이 되도록 되어 있어서 개발에 잇점이 있으리라 생각됩니다.
도메인 클래스 만들기#
앞서 만들어진 프로젝트 디렉터리로 이동한다.D:\temp\test>grails create-domain-class Welcome to Grails 1.0.4 - http://grails.org/ Licensed under Apache Standard License 2.0 Grails home is set to: D:\MyLucy\grails-1.0.4 Base Directory: D:\temp\test Note: No plugin scripts found Running script D:\MyLucy\grails-1.0.4\scripts\CreateDomainClass.groovy Environment set to development name not specified. Please enter: Person [copy] Copying 1 file to D:\temp\test\grails-app\domain Created Domain Class for Person [copy] Copying 1 file to D:\temp\test\test\integration Created Tests for Person
"name not specified. Please enter:" 메시지가 나오면 도메인 클래스명을 입력한다. 여기서는 Person을 입력했다. 처리 메시지를 보면 grails-app/domail 아래 도메인 클래스(여기서는 Person.groovy)가 생성되고 test/integration 아래 도메인 테스트 클래스(여기서는 PersonTests.groovy)가 생성된다.
컨트롤러 만들기#
역시 프로젝트 디렉터리에서 명령을 실행한다.D:\temp\test>grails create-controller Welcome to Grails 1.0.4 - http://grails.org/ Licensed under Apache Standard License 2.0 Grails home is set to: D:\MyLucy\grails-1.0.4 Base Directory: D:\temp\test Note: No plugin scripts found Running script D:\MyLucy\grails-1.0.4\scripts\CreateController.groovy Environment set to development Controller name not specified. Please enter: Person [copy] Copying 1 file to D:\temp\test\grails-app\controllers Created Controller for Person [mkdir] Created dir: D:\temp\test\grails-app\views\person [copy] Copying 1 file to D:\temp\test\test\integration Created ControllerTests for Person단 여기서 주의할 사항은 컨트롤러의 이름은 대문자로 시작하도록 한다.
Grails 시작하기#
grails run-app
웹브라우저를 통해 접속하면 된다.
SVN 셋팅하기#
신규 프로젝트로 등록하기#
svn checkout <svn-server-url>/emptysvndir/ . svn add * svn propset svn:ignore "WEB-INF" web-app/ svn rm --force web-app/WEB-INF svn rm --force plugins/core svn commit -m "First commit"
기존 프로젝트를 등록하기#
cd MyProject svn propset svn:ignore "WEB-INF" web-app/ svn rm web-app/WEB-INF svn rm plugins/core svn commit -m "Fixing SVN"
SVN에서 체크아웃하기#
grails upgrade
Add new attachment
Only authorized users are allowed to upload new attachments.
List of attachments
Kind | Attachment Name | Size | Version | Date Modified | Author | Change note |
---|---|---|---|---|---|---|
png |
grails1.png | 5.8 kB | 1 | 21-Dec-2008 17:33 | DongGukLee | |
png |
grails2.png | 3.1 kB | 1 | 21-Dec-2008 17:33 | DongGukLee |
G’day (anonymous guest)
My Prefs