A Play application can be assembled from several application modules. This allows you to reuse application components across several applications or split a large application into several smaller applications.

What is a module?

A module is just another Play application; however some differences exist in the way resources are loaded for an application module:

  • A module does not have a conf/application.conf file.
  • A module can have a conf/routes file, but these routes will not be loaded automatically.
  • All files are first searched for in the main application path, then in all loaded modules.
  • A module can contain plain Java code packaged as a JAR file in the module/lib directory.
  • A module can include a documentation page.
  • Everything in a module is optional.

You can create a module with the play new-module command.

How to load a module from an application

Modules are automatically loaded from the /modules directory of the application. You can use thedependencies management system to automatically manage your application modules.

Load default routes from modules

A module can provide a default routes file. You can load it in the main application routes file, using a special route declaration:

# Import the default CRUD routes
GET /admin module:crud

You can even load routes from all available modules:

GET     /	     module:*

Add documentation to a module

You can add a documentation page to a module simply by adding a the filedocumentation/manual/home.textile to the module. Use the same Textile syntax as the Play documentation itself, in ${play.path}/documentation/manual/.

If you are running a Play application that uses one or more modules with documentation, then the local Play documentation at http://localhost:9000/@documentation will include links to their documentation pages under Installed Modules in the side bar.

Using the module repository

The module repository identifies all modules contributed by the community. A module can have several versions. You have to check the module’s documentation for which version you need to use for your framework version.

You can also browse the module repository using the play list-modules command.

gbo-mac:~ guillaume$ play list-modules
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.2, http://www.playframework.org
~
~ You can also browse this list online at http://www.playframework.org/modules
~
~ [bespin]
~ Bespin online editor
~ http://www.playframework.org/modules/bespin
~ Versions: 1.0, 1.0.1
~
~ [cobertura]
~ Cobertura
~ http://www.playframework.org/modules/cobertura
~ Versions: 1.0
...

You can install a module locally using the play install {module}-{version} command. Installing a module locally allow to use it from several application without having to install a different copy in each application. It is useful for large modules that are more framework extensions than your application extension.

For example, to install the Scala support to the framework, use:

play install scala-head

By convention the head version is the unstable version of the module. You can also install the default version of a module by omitting the version information. For example:

play install scala

Modules installed this way are downloaded to the /modules directory of your framework installation.

You can change the installation path using the --path option:

play install gwt --path=my-project

Contributing a new module to the module repository

First you need to have an OpenID. It will help us to authenticate you as author of your modules. Then send us a module registration request on the Google Group.

Please tell us:

  • More about your module. What is it?
  • Your module name. It must match the [a-zA-Z]+ regular expression.
  • A short description of the module.
  • Your project home page.
  • Your OpenID.
  • Your module must be hosted somewhere with the source code available and a way to report bugs. If you don’t have any idea, github, Google Code and Launchpad are good choices.

To release your module, simply use the play build-module command. Then connect to the module repository and upload the generated package.

You can of course use the offical Google Group to provide help and share information about your work.

Continuing the discussion

Learn how efficiently manage your modules using Dependencies management.

Play modules的更多相关文章

  1. YII的Modules模块化

    转载来源: http://blog.csdn.net/mengxiangbaidu/article/details/7041296 http://blog.csdn.net/colzer/articl ...

  2. 在Angular1.X中使用CSS Modules

    在Angular1.5中,增加了一个Component方法,并且定义了组件的若干生命周期hook,在代码规范中也是推崇组件化开发,但是很遗憾的是,CSS模块化组件化的问题并没有得到解决,大部分项目的打 ...

  3. 如何在Mac系统里面更新 Ansible 的 Extra Modules

    最近遇到一个问题 seport is not a legal parameter in an Ansible task or handler 原因是我本地 Ansible 的 Extra Module ...

  4. Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web modules

    在eclipse里面配置tomcat时候遇到的问题: Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web mo ...

  5. 安装ESXi5.5遇到Relocating modules and starting up the kernel的处理

    在一些Dell较旧的服务器上安装ESXi 5.x时, 会遇到卡在Relocating modules and starting up the kernel过不去的问题. 比如我装的这台CS24VSS. ...

  6. PHPCMS \phpcms\modules\member\index.php 用户登陆SQL注入漏洞分析

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述2. 漏洞触发条件 0x1: POC http://localhost/p ...

  7. PHPCMS \phpsso_server\phpcms\modules\phpsso\index.php、\api\get_menu.php Authkey Leakage

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 安装phpcms的时候会强制安装它的通行证 Relevant Link: ...

  8. ecshop /includes/modules/payment/alipay.php SQL Injection Vul

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 ECSHOP支付插件存在SQL注入漏洞,此漏洞存在于/includes/ ...

  9. TypeScript Modules(模块)

    本文概述了TypeScript中如何使用模块以各种方式来组织代码.我们将涵括内部和外部的模块,并且讨论他们在适合在何时使用和怎么使用.我们也会学习一些如何使用外部模块的高级技巧,并且解决一些当我们使用 ...

随机推荐

  1. [Hadoop大数据]——Hive初识

    Hive出现的背景 Hadoop提供了大数据的通用解决方案,比如存储提供了Hdfs,计算提供了MapReduce思想.但是想要写出MapReduce算法还是比较繁琐的,对于开发者来说,需要了解底层的h ...

  2. Java异常内容总结

    在程序开发中,可能存在各种错误,有些错误是可以避免的,而有些错误却是意想不到的,在Java中把这些可能发生的错误称为异常. Throwable类是所有异常类的超类,该类的两个直接子类是Error和Ex ...

  3. 日志log2

    public class LoggerHelper2 { private static ConcurrentQueue<string> CqMsg = null; private stat ...

  4. C#中日期记忆日期的格式化,日期格式化说明

    参数format格式详细用法:格式字符 关联属性/说明 d ShortDatePattern D LongDatePattern f 完整日期和时间(长日期和短时间) F FullDateTimePa ...

  5. 视图必须派生自 WebViewPage 或 WebViewPage<TModel>

    后端汇总:http://www.cnblogs.com/dunitian/p/4523006.html#efmvc 后来发现原来吧web.config给删了 这就简单了,复制其他项目的web.conf ...

  6. Python标准模块--functools

    1 模块简介 functools,用于高阶函数:指那些作用于函数或者返回其它函数的函数,通常只要是可以被当做函数调用的对象就是这个模块的目标. 在Python 2.7 中具备如下方法, cmp_to_ ...

  7. IOS入门之Swift语言(一)

    经过不断的努力,小哥也买了台苹果设备,终于可以开始我的IOS之旅了,说来确实令人苦恼,为了学习IOS我这着贫农阶级,省了几个月的零花钱,外加向亲朋好友求救,最终痛下心扉,卖了台MAC pro128G版 ...

  8. 新作《ASP.NET Web API 2框架揭秘》正式出版

    我觉得大部分人都是“眼球动物“,他们关注的往往都是目光所及的东西.对于很多软件从业者来说,他们对看得见(具有UI界面)的应用抱有极大的热忱,但是对背后支撑整个应用的服务却显得较为冷漠.如果我们将整个“ ...

  9. AngularJS之高级Route【三】(八)

    前言 我们知道默认的路由提供(Route Provider)在复杂的应用程序中是不太适合应用场景,它存在诸多限制,所以在Angular 1.2之后此时我们不得不将路由提供作为一个单独的模块当我们需要使 ...

  10. (转)使用minicpan创建本地CPAN

    在临时的办公场所网络不畅,有时不能下载cpan上的软件包,所有只能自建一个cpan. 这里使用了工具'minicpan',简单地说:就是把互联网上的CPAN搬到自己的电脑里,它的最初想法来自Randa ...