使用dist命令后在哪里将公共目录放置在play框架中 [英] where to place the public directory for play framework after using the dist command

查看:180
本文介绍了使用dist命令后在哪里将公共目录放置在play框架中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在play框架v2.5中使用'dist'命令.但是,当我解压缩文件时,它不会创建公共目录.我有以下目录: bin,conf,lib,日志和共享(包含doc).

I am using the 'dist' command with play framework v2.5. However, when I unzip the file, it does not create the public directory. I have the following directories: bin, conf, lib, logs and share (contains doc).

我应该在哪里放置公共目录,使其与play框架完全一样(没有运行dist命令),即我可以将静态资产放置在公共目录中并从那里提供服务(我不这样做)希望到目前为止可以为此目的使用CDN.

Where should I place the public directory whereby this would work exactly like it does with the play framework (not having run the dist command) i.e. I can place static assets in the public directory and have them served from there (I do not wish to use a CDN for this purpose as of now).

理想情况下,我希望dist命令来处理它(与手动创建目录相反).静态路由会从公共目录中提供图片吗?还是我需要编写自己的控制器来提供这些静态资源?

I would ideally like the dist command to take care of it (as opposed to manually creating directories). Will the static route serve images from the public directory or do I need to write my own controller to serve these static assets?

推荐答案

答案中所述,请添加以下行进入您的/build.sbt文件.

As explained in this answer, add these lines into your /build.sbt file.

import com.typesafe.sbt.packager.MappingsHelper._
    mappings in Universal ++= directory(baseDirectory.value / "public")

这将在dist文件中包含"public"目录(您可以像这样包含任何目录).然后您的应用程序将在生产环境中运行.

That would include your 'public' directory inside the dist file (You can include any directory like that way). Then your application would work in the production environment.

这篇关于使用dist命令后在哪里将公共目录放置在play框架中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆