2010. 8. 27. 13:42 IT

 

프로젝트에서 다소 한가한 시간이라서 평소 생각만 하던 grails를 만들어보기로 했다.

작은 목표는 커뮤니케이션 포탈을 만들어보는것. (게으른 내게는 큰 목표다... )

 

  1. 설치
    두가지 방법이 있다. STS 를 설치하여 IDE환경에서 작업하는 것과, 콘솔에서 작업하는 방식

    • STS 설치방식
      - Java SDK 1.5+ 설치여부를 확인. (없으면 먼저 설치.. )
      - STS를 다운로드 한다. 주1)
      - 설치후 dashboard 화면에서 extensions tab 선택후
      Grails support, Groovy Eclipse 를 체크한다. (grails 는 뭔지 모르겠다.. 같이 설치했다.)
      - 설치후 리스타팅 하면 완료
      참고 : http://www.grails.org/STS+Integration
    • 콘솔 설치

      다운로드 사이트에서 grails를 다운로드 http://www.grails.org/Download

      환경변수 셋팅

      1. java home setting Java SDK 1.5+
        set JAVA_HOME=C:\Program Files\Java\jdk1.5.0
        # 설치위치 ( unix면 \대신 / )
        set GRAILS_HOME=c:\grails-1.3.4
        set PATH=%PATH%;%GRAILS_HOME%\bin
  2.  

  3.  GRAILS 프로젝트 만들기

    • STS에서 
      File > New > Grails Project  ... Done!
    • 콘솔에서
      >grails create-app my-project    ... Done!
  4.  도메인 클래스 만들기

    • STS에서
      Grails console을 open 주2)
      >create-domain-class speaker
    • 콘솔에서
      >grails create-domain-class speaker

      1. // Speaker.groovy 편집 
        package my.project
      2. class Speaker {
          String name
          String title
          String company

            static constraints = {
           name(maxSize:20)
           title(maxSize:50)
            }
        }
    • grails domain 설정
  5. 콘트롤러 클래스 만들기
    • STS에서
      Grails console을 open
      >create-controller my.project.Speaker
    • 콘솔에서
      >grails create-controller my.project.Speaker주3)
    • grails controller 설정 
  6.  실행
    • STS에서
      프로젝트에서 context menu > run as > grails command(run-app)
    • 콘솔에서
      >grails run-app

      cf) 실행시 hostname이 한글인 경우 ehcache에서 UnknownHostException 을 발생시키는데 기동에는 문제가 없다.

  7.  scaffodling template customizing

    1. 먼저 scaffolding template 을 사이트에 적절하게 변경하는 작업을 수행하는 것이 유용하다.
      커맨드 창 또는 grails 콘솔에서
      >grails install-templates 를 실행한다.
      그러면 src/templates 에 모든 템플릿 파일들이 생성된다.
    2.  해당 파일들에 대해 default 값들을 수정하여 사용하면 유용 ( 표준 주석 등도 만들어 두면 good.. )
  8.  JSP에서 gsp의 TLD 사용하기

    1. 최상단에 <%@ taglib prefix="g" uri="/WEB-INF/tld/grails.tld" %> 추가 
  9.  grails 설정

    grails -Dserver.port=9000 run-app
    

 http://www.tipstrs.com/tip/12727/Changing-the-port-of-a-Grails-project

 

jquery : grails install-plugin jquery
http://grails.org/plugin/jquery


주1) 현재 2.3.2가 release 된 상태다. http://www.springsource.com/products/springsource-tool-suite-download
주2) 단축키 Ctrl+Shift+Alt+G 또는 메뉴에서 Navigate > open Grails command prompt

주3) 다시 실행하는 경우 덮어쓸지 물어본다.

참고 사이트
http://www.howardism.org/Technical/Groovy/Grails_Advice.html

http://grailstutorials.com/tutorial

http://greatkim91.tistory.com/

이 글은 스프링노트에서 작성되었습니다.

posted by smplnote