开发者

What are the best methods for deploying java code to production?

开发者 https://www.devze.com 2023-02-04 13:19 出处:网络
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

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?

T开发者_运维知识库hanks


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.

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.

I would suggest to go through the following resources

  • 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.


There are several Maven plugins to help deployment. The most general of them is Cargo, but there are also app server specific plugins for some concrete servers like JBoss.


Most companies I have worked for (actually, all) have had some sort of custom in-house built deployment system; even if build was done using a standard framework (like Maven in use at my current company). Part of this is because there are many aspects that tie closely to company-specific infrastructure, capacity management and monitoring systems; and so even though there are open-source systems, there is usually something that needs to be tweaked.


It sounds like you are running your app on its own--it isn't part of any application server. If you aren't using an application server, there are probably some ways to get cargo and maven to deploy it for you, but you may be better off just using some shell scripts to deploy and run the application.

However, as your application grows, you may find a need for an application server like Jetty, JBoss, Glassfish, Tomcat, etc. When this happens, take a look at the cargo plugin for Maven because it will allow you to do something like:

mvn cargo:redeploy

That will package up your application, send it to the server and restart the app. If you want Hudson to do this for you automatically you can add it as a target to build.

Cargo can save you a lot of time when you have to frequently update an application server.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号