涉及的版本:Play! Framework 1.2.4。
本文介绍如何往Play!框架中添加新的module。
1、获取module列表;
可以通过命令行的方式:
play list-modules
或者直接访问网站:
[url]http://www.playframework.org/modules[/url]
2、安装模块;
在命令行中输入:
play install [module_name]
比如安装Redis的module,可以输入:
play install redis
接着会提问是否安装最新的版本:
输入y,回车继续。
以下是安装成功后的信息:
3、模块的使用;
一般每个模块都会带有使用文档,存放于[Play目录]\modules\[模块名称]\documentation下面,比如上面安装的redis模块的使用文档放于:play\modules\redis-0.3\documentation\manual。
在conf/dependencies.yml文件中添加play -> redis 0.3:
本文介绍如何往Play!框架中添加新的module。
1、获取module列表;
可以通过命令行的方式:
play list-modules
或者直接访问网站:
[url]http://www.playframework.org/modules[/url]
2、安装模块;
在命令行中输入:
play install [module_name]
比如安装Redis的module,可以输入:
play install redis
接着会提问是否安装最新的版本:
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.2.4, http://www.playframework.org
~
~
~ !! Warning: could not load core command fil
~
~ Will install redis-0.3
~ This module is compatible with:
~ Do you want to install this version (y/n)?
输入y,回车继续。
以下是安装成功后的信息:
~ Installing module redis-0.3...
~
~ Fetching http://www.playframework.org/modules/redis-0.3.zip
~ [--------------------------100%-------------------------] 12.2 KiB/s
~ Unzipping...
~
~ Module redis-0.3 is installed!
~ You can now use it by adding it to the dependencies.yml file:
~
~ require:
~ play -> redis 0.3
~
3、模块的使用;
一般每个模块都会带有使用文档,存放于[Play目录]\modules\[模块名称]\documentation下面,比如上面安装的redis模块的使用文档放于:play\modules\redis-0.3\documentation\manual。
在conf/dependencies.yml文件中添加play -> redis 0.3:
# Application dependencies
require:
- play
- play -> redis 0.3