播放dist任务:如何防止conf文件打包 [英] Play dist task: how to prevent conf files to be packed

查看:154
本文介绍了播放dist任务:如何防止conf文件打包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行dist任务时,分发程序包在两个位置包含conf文件(来自<app>/conf):

When running dist task, distribution package includes conf files (from <app>/conf) in two places:

  1. <app.zip>/conf
  2. <app.zip>/lib/<app.jar>
  1. <app.zip>/conf
  2. <app.zip>/lib/<app.jar>

这意味着application.conf(以及所有其他在<app>/conf中的conf文件)将同时放在zip包的根目录和主jar库的根目录中. 运行该应用程序时,将使用jar中的文件,因此<unzipped-app>/conf中的副本将被完全忽略.

This means that application.conf (and all the other conf files whithin <app>/conf) will be placed both in the root of the zip package, and in the root of the main jar library. When running the application, files inside jar are the ones used, so copies in the <unzipped-app>/conf are completely ignored.

我想知道哪种是最佳实践:我认为conf文件不应该打包在<app> jar中(可能是build.sbt上的某些表达式,可以将它们拒之门外?),但是可以在发行版zip中找到文件.因此,在解压缩和部署后,可以根据需要修改conf文件.

I'm wondering which is the best practice here: I think conf files should not be packed inside the <app> jar (may be some expression on build.sbt to keep them out?), but available in the distribution zip file. So, when unzipped and deployed, conf files can be modified as needed.

resourceDirectory似乎指向baseDirectory/'conf/',这个键是应该从packageBin任务中明确排除的那个键吗?

resourceDirectory seems to point to baseDirectory/'conf/', is this key the one that should be explicitely excluded form packageBin task?

推荐答案

您可以通过以下方式添加conf文件-

You can add your conf file in the following way -

  1. 转到应用程序构建文件夹.
  2. 键入以下命令-

  1. Go to app build folder.
  2. Type the following command -

java -Dapplication.secret ="mySecretKey" -Dconfig.resource = conf/application.conf -cp"lib/*;" play.core.server.NettyServer.

java -Dapplication.secret="mySecretKey" -Dconfig.resource=conf/application.conf -cp "lib/*;" play.core.server.NettyServer .

这篇关于播放dist任务:如何防止conf文件打包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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