如果还没有安装IDEA或者JetGroovy插件,请看我上一篇《安装IntelliJ IDEA JetGroovy》
http://wangcheng.iteye.com/blog/156885
    
      
        
          
            
              
                1.下载Grails
              
              
            
          
        
      
    
    
      http://grails.org/Download
    
    
    下载grails-bin-1.0.1.zip后,解压到硬盘。
    
    你也可以安照其它文档的介绍,配置环境变量等。
  
    
      
        
          
            
              2.配置JetGroovy插件
            
          
        
      
    
    
    File -> Settings -> IDE Settings -> Groovy&Grails 
    
    在Groovy的Groovy installation directory中设置Groovy的解压缩目录.
    
    在Grails的Grails installation directory中设置Grails的解压缩目录.
  
    
      
        
          
            
              
                3.创建一个Grails项目
              
            
          
        
        
      
    
    File -> New Project -> Create project from scratch 
    
    在Select type中选Grails Application
    
    在Name中输入一个项目名,比如myGrailsProject
    
    然后一路next,IDEA就会为你创建好Grails项目结构
  
    
      
        
          
            
              
                4.创建Controller
              
            
          
          
        
      
    
    New -> Grails -> Grails Controller
    
    输入一个Controller的名字,比如 hello
    
    然后就会打开一个HelloController.groovy的文件
    
    输入内容如下
  
    //groovy code
class HelloController {
   def index = {
        render "Hello World! my first Grails";
    }
}
  
  
            
              
                5.配置Run Configurations
              
            
            
            
              Run -> Edit Configurations
              
              点右上角的 "+" (Add New Configurations)
              
              选择Grails Application
              
              在Name中输入一个名字
              
              也可以在VM Parameters中写参数,比如修改port等
            
          
    
  
    
    
      
        
          
            
              6.启动
            
          
        
      
    
  
    直接Run就运行了。
    
    启动后会提示
    
    Server running. Browse to 
    
      http://localhost:8090/myGrailsProject
    
    
    访问
    
      http://localhost:8090/myGrailsProject
    
     然后点击HelloController 就可以看到输出了。
  
参考
http://grails.org/IDEA+Integration

