playframework-2.0 - Play Framework : no assets in production mode

标签 playframework-2.0 development-environment assets production-environment

我有一个奇怪的问题。我有一个用 Play 编写的应用程序!框架2.0.4。它使用一些公共(public)资源(css/images/javascript)。当我在开发模式下运行它时一切都很好:

blus@vmblus:~/svn/blus> play
[info] Loading project definition from /home/blus/svn/blus/project/project
[info] Loading project definition from /home/blus/svn/blus/project
[info] Set current project to blus (in build file:/home/blus/svn/blus/)
       _            _
 _ __ | | __ _ _  _| |
| '_ \| |/ _' | || |_|
|  __/|_|\____|\__ (_)
|_|            |__/

play! 2.0.4, http://www.playframework.org

> Type "help play" or "license" for more information.
> Type "exit" or use Ctrl+D to leave this console.

[blus] $ run

--- (Running the application from SBT, auto-reloading is enabled) ---

[info] play - Listening for HTTP on port 9000...

(Server started, use Ctrl+D to stop and go back to the console...)

资源在浏览器中加载没有任何问题。但是,当我想在生产模式下运行相同应用程序(未复制,未移动,只是相同)时, Assets 就消失了:

[blus] $ start 9000

(Starting server. Type Ctrl+D to exit logs, the server will remain in background)

Play server process ID is 6845
[info] play - Application started (Prod)
[info] play - Listening for HTTP on port 9000...

Firebug 显示:

"NetworkError: 404 Not Found - http://vmblus:9000/assets/stylesheets/main.css"

未找到所有需要的资源。这怎么可能?我该如何解决这个问题?

这是我的conf/routes的一部分:

GET /assets/*file controllers.ExternalAssets.at(path="public", file)

这就是我在 View 中调用我的 Assets 的方式:

<link rel="stylesheet" media="screen" href="@routes.ExternalAssets.at("stylesheets/main.css")">

我看到了this question ,但我的路径没有 //

最佳答案

您正在使用controllers.ExternalAssets.at而不是controllers.Assets.at

这很可能是原因。

关于playframework-2.0 - Play Framework : no assets in production mode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13724954/

相关文章:

javascript - AngularJS 中 Ember 夹具适配器的等效项

linux - 虚拟化 Linux 是否足够快以用于软件开发?

iphone - 有关运行 4.x 的旧手机上的视网膜显示资源的问题

java - 玩! 2.0 应用程序启动时数据库覆盖。 (MYSQL)

forms - Scala Play 表单验证 : different forms for one case class - is it possible?

playframework-2.0 - Play 如何帮助我防止参数篡改攻击?

flutter - 有关 Assets 影响绩效的问题

deployment - 在生产中更新 Play Framework 应用程序的最佳工作流程

c# - iPhone 编程 - 印象,意见?

css - 链接到静态 Assets ,自定义 MVC 应用程序 (PHP)