简体   繁体   中英

Deploying Java application on remote server using Maven

I am writing a Java application using Maven. I have to deploy the application on a remote powerful server to run experiments. The simplest way I figured out to do this was to build a jar-with-dependencies using Maven shading plugin and then copy the uber-jar to the remote server. However the jar is big, 100+ MB, and it takes some time to send it through our network. This is redundant because most of the jar consist of heavy dependencies (Scala, Spark, Jetty) and only a tiny portion of it changes when we change our code.

Can I use Maven to install the dependencies on the remote server and then only send the much smaller jar with no dependencies to the server?

I have SSH connection to the server and I can use the SCP plugin.

You mention Jetty in your question so I am assuming your application server is Jetty. I would try and upload the common library jars to the server and then including them in the jetty class path. This will be a one time task. Maybe this will help: How do I place jars in jetty/lib on the jetty classpath? .

After this you can use maven to built a "thin" war/jar which you can upload and deploy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM