Reputation: 4350
When I compile an uber jar from the command line via mvn package
and execute with java -jar target/my-jar.jar
, it fails with some dependencies conflicts.
When I execute from run/debug configuration, using Intellij's make, everything is fine!
Is there something different about Intellij's classpath? How would I go about figuring out the differences between the two builds?
Upvotes: 1
Views: 1598
Reputation: 4350
I figured it out myself and learned a couple of things along the way. The problem turned out to be my maven shade plugin which was using
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
Even if you exclude transitive dependencies religiously, that transformer will still concatenate classes defined transitively and can cause issues with hk2 not finding the class it needs to inject dependencies. I was excluding some classes in order to prevent my application from running both Jersey 1 and Jersey 2. Removing that line fixed things for me and matched the behavior in Intellij.
Some potential differences between the artifact produced by mvn package
and running a build with Intellij:
mvn dependency:list -Dsort=true
and sorting the screen in Project Settings > modules > {your module} > dependencies (tab).dependency:list
and dependency:tree -Dincludes=the.groupIid:the.artifact
to track down where some transitive dependencies came from.Upvotes: 2