通过maven部署到生产环境
我想在 Maven 中创建一个目标,将我的 java web 应用程序部署到生产 tomcat 7 实例。执行此操作的最佳方法是什么?我希望有一个插件可以处理 SFTP 战争并告诉 tomcat 重新加载。该插件需要在出现问题时处理回滚,将更新的静态文件上传到 S3(为其重置云端缓存)并可能同步数据库更新。
这是否需要在 Maven 之外运行脚本?或者这种自动部署功能最好用 Ant 来完成吗?
I'd like to create a goal in maven to deploy my java webapp to production tomcat 7 instances. What's the best way to go about doing this? I'm hoping there's a plugin that handles SFTP'ing the war and telling tomcat to reload. This plugin would need to handle rollbacks in case of issues, uploading updated static files to S3 (resetting cloudfront caches for them) and possibly synchronizing db updates.
Does this demand a script run outside of Maven? Or is this auto-deploy functionality best accomplished with Ant?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 cargo-maven-plugin 来实现此目的。它不会SFTP,它可以直接远程部署到Tomcat。如果您需要 sftp,您可以使用 wagon-plugin 来 scp 文件并通过 Cargo-plugin 重新启动 Tomcat。静态文件可以由 wagon-plugin 处理(但我当时不确定)。
此外,您不需要创建目标(这意味着您将编写一个插件)。
我建议创建一个单独的 maven 项目,它依赖于您想要部署到生产环境的 war 文件。
You can use the cargo-maven-plugin to achieve this. It will not SFTP it can directly remotely deploy to the Tomcat. If you need sftp you can use the wagon-plugin to scp the file and do a restart of Tomcat via cargo-plugin. Static files could be handled by the wagon-plugin (but i'm not sure at that point).
Furthermore you don't need to create goal (which would meant you will write a plugin).
I would suggest to create a separate maven-project which has the dependency to the war file you would like to deploy to production.
对于数据库更新部分,我建议使用 Liquibase (它还处理回滚)。我还不知道如何进行部署回滚,但也许如果您使用 Maven 发布插件或任何其他发布管理方式,您可以手动部署以前的版本。
For the DB updates part I would suggest using Liquibase (it also handles rollbacks). I don't know yet how you would do a deployment rollback but maybe If you're using the maven release plugin or any other way of release management you could manually deploy the previous release.
使用elastic beanstalk和maven beanstalk插件怎么样?
how about using elastic beanstalk and the maven beanstalk plugin?