Grails 정리#

- 프로젝트 생성 -
>grails create-app
프로젝트명 입력

- 프로젝트 실행
>grails run-app

- 도메인 클래스 생성
>grails create-domain-class
생성할 도메인 클래스 입력

- 컨트롤 생성
>grails create-controller

Grails 프레임워크#

Trails (Hibernate / Spring / Tapestry 기반)
Grails  = (Spring  + Hibernate  + SiteMesh ) * Implementation by Groovy 

공식 Site		http://www.grails.org
Grails란 무엇인가?	http://docs.codehaus.org/display/GRAILS/Korean+Home
Grails 설치		http://www.grails.org/Korean+Installation
Grails 빠르게 시작 하기 http://grails.codehaus.org/Korean+Quick+Start
Grails 콘솔		http://grails.org/Korean+Command+Line+Tools
Grails GORM(OR맵핑)	http://grails.codehaus.org/Korean+GORM

Grails 스크린 캐스팅 정리#

# grails create-app

명령어 입력 : bookapp

# cd bookapp/
# ls -laF

# grails run-app

웹브라우져 : http://localhost:8080/bookapp

# grails create-domain-class

명령어 입력 Book

# vi grails-app/domain/Book.groovy
Long version 밑에 추가
String author
String title
Date releaseDate
String description

def constraints = {
	title()
	author(inList:["graeme Rochder", "Dierk Koenig"])
	releaseDate()
	description(widget:'textarea')
}

# grails generate-all

명령어 입력 Book

# grails run-app

브라우져로 접속하면 북 컨트롤러가 자동 생성됨

Grails 오라클 연동#

grails-bin-0.2.2 를 이용하여 정리 함

오라클에 테이블과 시쿼스 생성
CREATE TABLE comics (
      id NUMBER(10) NOT NULL,
      title VARCHAR2(60),
      issue NUMBER(4),
      publisher VARCHAR2(60),
      PRIMARY KEY (id)
);
CREATE SEQUENCE comics_seq;




> grails create-app
....
.....
create-app:
    [input] Enter application name:
comics_catalog
..... 



> cd comics_catalog
> grails create-domain-class
....
create-domain-class:
    [input] Enter domain class name:
comics
....




/comics_catalog/grails-app/domain/Comics.groovy

class Comics { 
    @Property Long id
    @Property Long version

    // new properties for the Comics class
    @Property String title
    @Property Long issue
    @Property String publisher

    String toString() { "${this.class.name} :  $id" }
} 

> grails generate-all
....
input-domain-class:
    [input] Enter domain class name:
comics
.... 




./comics_catalog/grails-app/controllers
./comics_catalog/grails-app/views






./comics_catalog/grails-app/conf/DevelopmentDataSource.groovy
class ApplicationDataSource {
   @Property boolean pooled = true
   @Property String dbCreate = "update" // one of 'create', 'create-drop','update'
   @Property String url = "jdbc:oracle:thin:@localhost:1521:XE"
   @Property String driverClassName = "oracle.jdbc.OracleDriver"
   @Property String username = "ruby"
   @Property String password = "ruby"
}




ojdbc14.jar 파일을 ./comics_catalog/grails-app/lib 폴더에 복사



서버 실행
grails run-app 



포트 수정
grails -Dserver.port=9090 run-app


http://localhost:8080/comics_catalog/comics/

Grails MySql 연동#

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-) was last changed on 17-May-2021 01:15 by UnknownAuthor