On a whim, I want to use eclipse to package the jar of a spring project and run it with java -jar
The packaged jar of the export that was used directly for the first time, after packaging, it will not run
I just remembered that this kind of packaging requires another jar package of this project to be written in the -cp method.
So use export runnable jar file to package
eclipse provides 2 options
1.Extract required libraries into generated JAR Extract the code to be used and put it into the result jar
2.package required libraries into generated JAR directly put the third-party packages to be used into the resulting jar
Try it, you can
When using 2, be careful not to repeat the next package, otherwise it will not work
There is org.springframework.context-3.0.1.RELEASE-A.jar in lib
Then I put another Spring.jar in it, but it doesn't work after packaging
Record it yourself, don't make the same mistake next time