Grails mac 下入门教程
2015-12-12 19:23
429 查看
1.安装前的准备
1.1安装对应操作系统的jdk版本,比如grails3.0 需要jdk1.7以上的版本。建议从www.oracle.com官网上下载。
1.2当然如果需要自动安装的话 可以使用GVM tool 来一步安装 http://sdkman.io/ 进行安装,不过建议手动安装一遍。
1.3以下为grails的安装步骤
1.3.1下载grails压缩包 选择自己需要的版本进行安装 https://github.com/grails/grails-core/releases?after=v2.2.4
1.3.2 设置GRAILS_HOME 环境变量 例如在mac下的话
1.3.3 添加bin目录到path变量
export PATH="$PATH:$GRAILS_HOME/bin"
1.3.4 查看grails是否安装成功。终端下输入 grails
-version
1.4
grails常用命令
grails create-app HelloWorld 此命令会在当前目录创建HelloWorld目录
然后你可以查看下该目录下的
文件
cd HelloWorld 然后 ls查看下
输入grails
在grails
框架下 你任何时候想要创建一个新的页面,你需要创建一个 controller action
输入
create-controller hello 可用tab键补全
在对应的controller下面
写上自己的方法,例如
输入 run-app 启动grails 内置的容器服务器 如果端口占用 也可以用 run-app -port=9090来运行(1024
to 49151)
http://localhost:8080/ 查看下 是否能看到你刚才创建的helloworld
一个controller是可以包含很多和action的来展现不同的页面
/<appname>/<controller>/<action> 这是grails的url组成部分
<controller>
= remove the 'Controller' suffix from the class name and lower-case the first letter
'index' is the default
action
Convention over Configuration
建议容器用Tomcat 7
另外快速的创建一个应用 可以用
1.1安装对应操作系统的jdk版本,比如grails3.0 需要jdk1.7以上的版本。建议从www.oracle.com官网上下载。
1.2当然如果需要自动安装的话 可以使用GVM tool 来一步安装 http://sdkman.io/ 进行安装,不过建议手动安装一遍。
1.3以下为grails的安装步骤
1.3.1下载grails压缩包 选择自己需要的版本进行安装 https://github.com/grails/grails-core/releases?after=v2.2.4
1.3.2 设置GRAILS_HOME 环境变量 例如在mac下的话
export GRAILS_HOME=/path/to/grails
1.3.3 添加bin目录到path变量
export PATH="$PATH:$GRAILS_HOME/bin"
1.3.4 查看grails是否安装成功。终端下输入 grails
-version
1.4
grails常用命令
grails create-app HelloWorld 此命令会在当前目录创建HelloWorld目录
然后你可以查看下该目录下的
文件
cd HelloWorld 然后 ls查看下
输入grails
在grails
框架下 你任何时候想要创建一个新的页面,你需要创建一个 controller action
输入
create-controller hello 可用tab键补全
在对应的controller下面
写上自己的方法,例如
package helloworldclass HelloController { def index() { render "Hello World!" } }
输入 run-app 启动grails 内置的容器服务器 如果端口占用 也可以用 run-app -port=9090来运行(1024
to 49151)
http://localhost:8080/ 查看下 是否能看到你刚才创建的helloworld
一个controller是可以包含很多和action的来展现不同的页面
/<appname>/<controller>/<action> 这是grails的url组成部分
<controller>
= remove the 'Controller' suffix from the class name and lower-case the first letter
'index' is the default
action
Convention over Configuration
grails -Dserver.port=8090 run-app stop-app' to shutdown
如果你的需要另外部署tomcat的话 则需要额外指定web容器 可以在build.gradle 下指定
provided "org.springframework.boot:spring-boot-starter-tomcat"
部署对应的应用的话 grails war 默认是生产包 如果需要开发包的话 grails dev war
建议容器用Tomcat 7
另外快速的创建一个应用 可以用
grails generate-all applicationName
相关文章推荐
- 为什么mfc的入口是InitInstance()而没有WinMain()
- 盘点过去一年,MIT人工智能实验室的那些创新
- 人工智能终于能像人类一样学习,并通过了图灵测试
- 浅析C++中虚函数的调用及对象的内部布局http://blog.csdn.net/starlee/article/details/2089358
- MFC中的Invalidate、OnDraw、OnPaint函数的作用
- Daily Scrum 12.12
- Could not find gem 'sass-rails (~> 5.0) x64-mingw32' in any of the gem sources listed in your Gemfil
- 清空缓冲区的方法http://blog.csdn.net/thecorr/article/details/1922541
- scanf/fscanf 的%[]和%n使用方法 http://blog.csdn.net/wesweeky/article/details/6439777
- scanf 编辑 http://baike.baidu.com/link?url=ZFdRhILOqU1Yhds34bLuhgtnQ8TAeRvh6l0asTq9uklyexmtnHPyrOuD5cV
- wait() 与 sleep
- Agent admitted failure to sign using the key
- Donald Trump vs. the Modern Political Campaign
- sublime There are no packages available for installation错误
- 设置 DB2 和 AIX 与条带技术匹配以提高 I/O 性能
- Updating classpath container 提示更新屏蔽
- Daily Scrum 12.11
- 【Beta】Daily Scrum Meeting第六次
- Warning: (vsim-3534) [FOFIR] - Failed to open file "sp_rom_8x256_sr.mif" for reading.
- Daily Scrum NO.4