如何在Warbler中添加META-INF/context.xml

3
如何将META-INF/context.xml添加到war包中?我在config/warble.rb文件中没有找到任何配置入口。
3个回答

3
很不幸,Nick的方法行不通。该文件实际上被复制到了WEB-INF/META-INF/context.xml。
我终于找到了一种将context.xml复制到META-INF的方法:
1.在Rails应用程序根目录下创建META-INF/context.xml;
2.取消注释并更改config/warble.rb中的以下行:
config.public_html = FileList["public/**/*", "doc/**/*", "META-INF/context.xml"]
基本上将META-INF视为public_html,并将其复制到webapps/youapp/META-INF。

2
顺便说一句,为了让它稍微简单些,你可以只需添加到默认值中: config.public_html += FileList["META-INF/context.xml"] - Araxia
你可以点击绿色勾号来接受自己的答案。 - Brian Tompsett - 汤莱恩

0

你需要自己添加一个。你可以在项目中创建一个 META-INF/context.xml 目录和文件,并将 META-INF 添加到 config/warble.rb 中的 config.dirs,或者你可以添加一个“pathmap”来将 context.xml 文件重命名为 war 文件中的 META-INF 目录。

config.pathmaps.application += ["%{context.xml,META-INF/context.xml}p"]

1
上述方法行不通。文件实际上被复制到 WEB-INF/META-INF/context.xml 中。 我终于找到一种方法来将 context.xml 复制到 META-INF 文件夹下:
  1. 在 Rails 应用程序根目录下创建 META-INF/context.xml 文件
  2. 取消 config/warble.rb 中以下行的注释并修改 config.public_html = FileList["public//*", "doc//*", "META-INF/context.xml" ]
基本上将 META-INF 视为 public_html,它将被复制到 webapps/youapp/META-INF。
- Bewang

0
更好的解决方法可能是在您的warble.rb文件中使用以下内容。
config.script_files << 'path_to_file/context.xml'

请查看文档,位于https://github.com/jruby/warbler/blob/master/lib/warbler/config.rb底部。

# These file will be placed in the META-INF directory of the jar or war that warbler
# produces. They are primarily used as launchers by the runnable feature.
attr_accessor :script_files

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接