将Java代码部署到生产中的最佳方法是什么?

问题描述:

当前,我们有一个Java Restlet API,其依赖关系是通过Maven控制的.当我们更新API时,我们运行maven assembly:assembly,它对单元进行测试等等,并生成一个jar文件.然后,我们将其上传到生产服务器并使用nohup运行它.

Currently we have a Java Restlet API with dependencies controlled via Maven. When we update the API we run maven assembly:assembly which does the unit tests etc and produces a single jar file. We then upload this to the production server and run it using nohup.

是否有更好或更自动化的方法?像哈德森这样的地方会进来吗?

Is there a better or more automated way of doing this? Is this where something like Hudson would come in?

谢谢

我的经验涉及到webapp部署.但是,这里也应如此.使用 Maven 货物 Nexus (或哈德森,可能还包括 Jira .

My experience goes with webapp-deployment. But same should hold true here. Use Maven, Cargo, Nexus (or Artifactory), Hudson and probably, Jira in conjunction of product release.

自动发布过程更可靠,因为其中没有人为因素可能会忘记一个步骤.

Automated release process are more reliable because there is no human factor involved that may forget a step.

我们还将Liquibase用于数据库版本控制.并且,如果您要处理应用程序部署中的数据库更改.您会发现Liquibase在运行Alter脚本时大大增强了信心.

We also use Liquibase for database versioning. And, if you are dealing with database changes in your application deployment. You'll realize Liquibase boosts so much confidence while running alter scripts.

我建议您阅读以下资源

  • Automated Deployment with Maven - going the whole nine yards If you can, literally follow this pattern.
  • Maven 2 Effective Implementation -- this book really helped us a lot.