为什么使用 Warbler 时 db 目录不包含在 JRuby WAR 中?
我创建了一个简单的“hello”类型 JRuby 应用程序,并使用 Warbler 进行 WAR,然后部署到 JBoss。但是,在使用该应用程序时出现以下错误:
ActiveRecord::JDBCError (驱动程序遇到未知错误:java.sql.SQLException: path to '/opt/jboss/server/ruby/tmp/deploy/tmp8791905909469840942demo -exp.war/WEB-INF/db/development.sqlite3': '/opt/jboss/server/ruby/tmp/deploy/tmp8791905909469840942demo-exp.war/WEB-INF/db' 不存在):
果然,当我深入研究 demo.war 文件时,db 目录是WEB-INF 目录中丢失。 db 目录与测试、开发和生产数据库文件一起存在于应用程序目录中。
有什么想法吗?
I've created a simple 'hello' type JRuby application and use Warbler to WAR up and then deploy to JBoss. However, I get the following error when using the application:
ActiveRecord::JDBCError (The driver encountered an unknown error: java.sql.SQLException: path to '/opt/jboss/server/ruby/tmp/deploy/tmp8791905909469840942demo-exp.war/WEB-INF/db/production.sqlite3': '/opt/jboss/server/ruby/tmp/deploy/tmp8791905909469840942demo-exp.war/WEB-INF/db' does not exist):
Sure enough when I dig into the demo.war file the db directory is missing from WEB-INF directory. The db directory exists in the app directory though along with test, development and production database files.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常 db 目录仅包含迁移。如果您使用的是 sqlite3,它包含数据库文件,但由于当您在生产中部署战争时,它会在服务器内部的某个位置解压缩,并可能在重新部署时被删除,因此您的数据库文件将随着重新部署而消失。如果该文件是只读的并且您不担心这种情况,那么您可以通过运行
warble config
并编辑config/warble.rb
轻松添加 db 目录,将db
添加到config.dirs
数组。Usually the db directory contains migrations only. If you're using sqlite3 it contains the database file, but since when you deploy a war in production it gets unpacked somewhere in the server innards and potentially gets deleted on redeploy, your database file would go away with the redeploy. If the file is read-only and you're not worried about that consideration then you can easily add the db directory by running
warble config
and editingconfig/warble.rb
and addingdb
to theconfig.dirs
array.