I have a spring based application that does a component/package scan looking for packages within a certain namespace. The application runs perfectly in Eclipse and I\'d like
use Maven Shade Plugin for create uberjar. This could help you too.
You can use your option 1 Maven Compile to a single jar with additional goal parameters.
mvn clean package spring-boot:repackage
It will create the standalone jar file with Spring autoload functionality.
I just had the very same problem than you today, with doing exactly the same steps :)
So thanks for your message, it makes me save some time and besides, i just want to quickly answer to your "Why it worked is still a mystery." sentence :
"This is because I have several Spring Jar in my dependencies. Some of the spring jars contain meta info files with the same name. To avoid that some meta files are overridden you have to merge it"
So this is why you need to add those two transformers to the maven snippet given into the Maven Shade Plugin documentation :
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"
<resource>META-INF/spring.schemas</resource>
</transformer
source : http://robert-reiz.com/2011/11/14/832/
Hope it helps for understanding ;)
try this one in eclipse: in the menu choose File -> Export -> Runnable JAR file
in the specification window:(after filling other blanks properly) Library handling : Select the second one
and Finish
now try the following command in cmd or terminal: java -jar [your project's name]
Hope it helps