How do we deploy the binary dependencies?

Let's say we have a simple Java project compiles into a simple.jar with its POM depends on log4j.jar. When I open the simple-1.0.jar, inside there is no log4j.jar. And then we upload this simple-1.0.jar onto Nexus.

Now when deploy this simple-1.0.jar to the target server, how do we deploy the log4j.jar?

Thanks Jirong

Answers


You can either package the dependencies with your application (i.e. create an uber-jar, WAR, or EAR file) or you can deploy the dependent jars to a location on the server and then set that location as the classpath when you run the jar.

Packaging an application as an Uber-JAR

One way of creating an uber-jar with Maven would be to use the maven-shade-plugin

Deploying the dependent jars and setting classpath

In this scenario you would create a "libs" folder somewhere on the target machine and copy all of the dependent jars into this folder.

Then when you launch your application you would set the classpath like so:

java -classpath /{libs directory} -jar simple-1.0.jar

Multiple classpath entries can be specified by separating them with a : like also:

java -classpath /{directory1}:/{directory2} -jar simple-1.0.jar

You can have Maven list the resolved dependencies using the dependency plugin:

mvn dependency:list

Need Your Help

AngularJS - Formatting ngModel on custom datepicker directive

angularjs parsing templates datepicker directive

I'm using JQuery bootstrap datepicker (eternicode.github.io/bootstrap-datepicker/) in an angular application.

Rotation of SubView according to it's superview

ios storyboard subview autorotate

I had created an application using story board with auto layout support. Now i want to add an loading view on request/response. I had created loading view by code like this