Skip to content

Instantly share code, notes, and snippets.

@arvindkgs
Last active October 3, 2021 19:18
Show Gist options
  • Save arvindkgs/1089993299bf9994aada23d777c538ad to your computer and use it in GitHub Desktop.
Save arvindkgs/1089993299bf9994aada23d777c538ad to your computer and use it in GitHub Desktop.
[maven] maven

Initalize mvn wrapper for project

  1. Run mvn -N io.takari:maven:wrapper in project root

Run individual tests

mvn -Dtest=TestClass test

Skip tests

mvn install -DskipTests

Build

  1. With tests - ./mvnw clean install
  2. Without tests - ./mvnw clean install -Dmaven.test.skip=true

Run

  1. spring-boot
    1. Without args mvn spring-boot:run
    2. With JVM args mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=dev -Xdebug"

Clear local repository (.m2)

  1. mvn dependency:purge-local-repository

Goals

spring-boot:build-image [Package an application into a OCI image using a buildpack.]

spring-boot:build-info [Generate a build-info.properties file based the content of the current MavenProject.]

spring-boot:help [Display help information on spring-boot-maven-plugin. Call mvn spring-boot:help -Ddetail=true -Dgoal= to display parameter details.]

spring-boot:repackage [Repackage existing JAR and WAR archives so that they can be executed from the command line using java -jar. With layout=NONE can also be used simply to package a JAR with nested dependencies (and no main class, so not executable).]

spring-boot:run [Run an application in place.]

spring-boot:start [Start a spring application. Contrary to the run goal, this does not block and allows other goals to operate on the application. This goal is typically used in integration test scenario where the application is started before a test suite and stopped after.]

spring-boot:stop [Stop an application that has been started by the "start" goal. Typically invoked once a test suite has completed.]

Dependency

  1. Get dependancy tree - ./mvnw dependency:tree
  2. Download sources - ./mvnw dependency:source

Debug

To debug mvnDebug spring-boot:run -Dspring-boot.run.fork=false and on Intellij Idea create new run Remote JVM Debug configuration, leaving all values same, except set port as 8000

Test

mvn test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment