(Quick Reference)

2.1 安装的前提条件 - Reference Documentation

Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith

Version: null

2.1 安装的前提条件

Before installing Grails you will as a minimum need a Java Development Kit (JDK) installed version 1.6 or above and environment variable called JAVA_HOME pointing to the location of this installation. On some platforms (for example OS X) the Java installation is automatically detected. However in many cases you will want to manually configure the location of Java. For example:

export JAVA_HOME=/Library/Java/Home
export PATH="$PATH:$JAVA_HOME/bin"

Note that although JDK 1.6 is required to use Grails at development time it is possible to deploy Grails to JDK 1.5 VMs by setting the grails.project.source.level and grails.project.target.level settings to "1.5" in grails-app/conf/BuildConfig.groovy:

grails.project.source.level = 1.5
grails.project.target.level = 1.5

In addition, Grails supports Servlet versions 2.5 and above. If you wish to use newer features of the Servlet API (such as 3.0) you should configure the grails.servlet.version in BuildConfig.groovy appropriately:

grails.servlet.version = "3.0"

在安装Grails以前,你至少需要先安装1.6或者更高版本的JDK,并且设置名为JAVA_HOME全局环境变量来指向它。有些平台(比如OS X),Java的安装是自动检测的,但是还是有不少的平台是需要手工来配置Java的安装位置的,比如:

export JAVA_HOME=/Library/Java/Home
export PATH="$PATH:$JAVA_HOME/bin"

注意!虽然Grails的开发环境是需要JDK 1.6,但是仍然可以将其应用发布于JDK 1.5 VM上,这可以通过设置grails-app/conf/BuildConfig.groovy中的grails.project.source.levelgrails.project.target.level值为"1.5":

grails.project.source.level = 1.5
grails.project.target.level = 1.5

此外,Grails支持的Servlet版本至少是2.5。如果你想使用最新的Servlet API(比如3.0)特性,你需要配置BuildConfig.groovy中的grails.servlet.version为合适的值才行,比如:

grails.servlet.version = "3.0"