通过 Tomcat 配置将变量传递到 JRuby 应用程序
在部署为 WAR 文件的 JRuby 应用程序中配置变量的最佳方法是什么?操作组需要根据我的应用程序的部署位置配置数据库设置和其他环境变量。由于它是 WAR 文件,因此它们无法直接访问 database.yml 或任何环境文件。
我希望能够改变他们需要配置的任何内容,并让他们将一些内容放入 Tomcat app.config/web.config 中。这可以吗?如何将这些值引入 JRuby?
What's the best way to configure variables in a JRuby application that's deployed as a WAR file? The operations group will need to configure database settings and other environment variables depending on where my app is deployed. Since it's a WAR file though they don't have direct access to the database.yml or any of the environment files.
I want to be able to variablize anything they need to configure and have them perhaps put something into the Tomcat app.config/web.config. Is this possible to do? How do you bring those values into JRuby?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,我发现,在 JRuby 中从 Tomcat servlet 上下文获取参数非常简单:
例如,如果我在 web.xml 中定义了以下内容:
您可以按如下方式访问 JRuby 中的值:
这将返回字符串“jdbc: h2:localhost/~/test_db"。
So to get parameters from the Tomcat servlet context in JRuby is very simple I discovered:
So for example if I had the following defined in the web.xml:
You can access the value in JRuby as follows:
This would return the string "jdbc:h2:localhost/~/test_db".