For each modification in spring I do the following:
mvn clean package
that instruction takes 1 min (which is a lot)
then I run the jar that was packed in the target folder
java -jar nombreDelJar.jar
Do I have to execute these instructions every time I make changes? Is there no other way that is faster?
it is
followed by
As its name suggests,
clean
it deletes all classes generated in the build (basically thetarget
) directory.package
does all the steps from compilation to packaging. If a module has not been modified, it does not recompile it.Doing
clean
it forces you to recompile the entire project, while doingmvn package
it alone will only recompile the affected modules.Whether that makes the process faster will depend on how you have structured the program in modules.
UPDATE: If what you want is to run from Maven, it is not a default functionality but there is a plugin for that:
(inside build->plugins)
Unfortunately, it doesn't seem that the official website ( https://www.mojohaus.org/exec-maven-plugin/ ) is up (although it's still a problem with my corporate connection) so I can't give the exact configuration.
So you can do:
To make the package first and then execute the plugin goal
exec
`exec.If you want everything to run as part of the maven lifecycle, you'll need to associate the plugin with a lifecycle stage using the
<execution>
; for example you can see it in Spanish or in English but better explained .And if all that fails, you can always do a .bat or a .sh :-p
Try
mvn spring-boot:run
to run the application.Every time you need to create the Jar you must execute those commands,
I leave you the following command that will take less time, since it does not execute the tests or does not look for them to exist
mvn clean install -Dmaven.test.skip=true
Cheers