Playframework:"游戏开始"的奇怪行为 - 缓存问题?

Wei*_* Ma 3 playframework playframework-2.0

我目前正在使用播放框架2开发一个Web应用程序.我在/ public目录下创建了一个文件夹"files".当我使用"play run"启动服务器时,可以访问该目录下的所有资源.

部署到服务器后.我通过运行"play start"启动服务器,发现"files"下的资源不再存在.

我想知道"play start"和"play run"之间不一致的原因是什么

更新:经过几次试验.我发现这是新上传的资源无法显示.方案如下:

1. play start --> server starts.
2. use application to upload a few images to the server.
3. try to display the uploaded image --> nothing is shown. browser shows the resource is not accessible.
4. kill the server process with task manager.
5. rm RUNNING_PID
6. run play start again 
7. Try to display the uploaded image --> now the images are showing.
Run Code Online (Sandbox Code Playgroud)

因此,看起来像"播放开始"的"热更新"问题我是否可以做任何配置让服务器接受更改?谢谢.

小智 6

你在哪里存储图像?在编译时,静态资产从中复制/public/target/scala-2.9.1/classes/public.此目录是类路径的一部分,资产从那里提供.因此,如果您在运行时存储文件,则应找到它们.

旁注:这可能不是一个可持续的解决方案,因为在下一次构建期间会删除用户加载的图像.也许您应该考虑在应用安装之外使用符号链接(注意!安全问题!)或将资产存储在其他地方,数据库或S3始终是很好的选择.