where to place the public directory for play framework after using the dist command

寵の児 提交于 2019-12-24 17:50:02

问题


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).

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).

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?


回答1:


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")

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.



来源:https://stackoverflow.com/questions/36704962/where-to-place-the-public-directory-for-play-framework-after-using-the-dist-comm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!