java - Running jar, setting classpath -


I have a project that I have created with Maven, I compile a jar with "MVN package", and Now I want to run it without setting some mad squares, because it depends on the spring and half the internet or something is there any way I can run smoothly? Something like "MVN Run" would be very good, or there would be an option to throw all the dependencies in the jar so that I can "java -jar". It would also be fantastic.

How do you handle it, and what do you recommend to do? Because exporting a CLASSPATH based on ~ / .m2 would hardly be harmful; -)

Cheers

Nick

- It will automatically create a jar with all your dependencies, and you can set the main square parameter to make it just executable.

The document can be confusing, so this is an example of what your POM would look like:

  & lt; Build & gt; & Lt; Plugins & gt; & Lt; Plugin & gt; & Lt; ArtifactId & gt; Maven-Assembly-Plugin & lt; / ArtifactId> & Lt; Version & gt; 2.1 & lt; / Edition & gt; & Lt; Configuration & gt; & Lt; DescriptorRefs & gt; & Lt; DescriptorRef & gt; Jarar-with-Dependency & lt; / DescriptorRef & gt; & Lt; / DescriptorRefs & gt; & Lt; Collections & gt; & Lt; Appearance & gt; & Lt; MainClass & gt; Package.of.my.MainClass & lt; / MainClass & gt; & Lt; PackageName & gt; Package.of.my & lt; / PackageName & gt; & Lt; / Reveal & gt; & Lt; / Collection & gt; & Lt; / Configuration & gt; & Lt; / Plugin & gt; & Lt; / Plugins & gt; & Lt; / Create & gt;  

And then you can run in this form:

  mvn assembly: assembly  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -