How to package and compile java using maven


 description

How to use maven to quickly compile and package java applications, through the command line mvn command to quickly achieve

In the example we clear the working directory and package the build

 command

mvn clean package -DskipTests

 parameter

clean : attempts to clean the files and directories generated by Maven during its build
package :  will compile your code and also package it
 -DskipTests : To skip running the tests for a particular project

 result

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.168 s
[INFO] Finished at: 2022-04-27T17:09:26+08:00
[INFO] ------------------------------------------------------------------------
Was this helpful?

I hope to help every developer quickly find the commands they need. Of course, you can also add your own commonly used commands for easy searching.