Maven Default Lifecycle Phases
Fast recall
Quick revision
Core answer
validate, compile, test, package, verify, install, and deploy, with other phases between them. Invoking a phase runs earlier phases in that lifecycle, but actual work depends on plugin goals bound by the packaging and POM. verify runs integration tests only when a plugin such as Failsafe is configured for the relevant phases.Core Maven knowledge — knowing the lifecycle order is essential for understanding what happens during any Maven command
Not knowing that install puts the artifact in the local ~/.m2 repository, not that it deploys to a production server
Explain the difference between install (local repo) and deploy (remote repo) clearly, showing you understand artifact distribution
Interview-ready guide
Interview answer
The main default-lifecycle milestones are validate, compile, test, package, verify, install, and deploy. Asking for a later phase makes Maven visit earlier phases in order. With normal JAR bindings, mvn package compiles, runs configured unit tests, and creates the archive.
I would not say phase names guarantee work by themselves. Plugin goals bound to those phases do the work, tests can be absent or skipped, and integration tests require configuration such as Failsafe. Install writes to the local Maven repository; deploy publishes to a configured remote Maven repository.
Maven Default Lifecycle Phases
Direct Answer
Important default-lifecycle phases in order include validate, compile, test, package, verify, install, and deploy, with other phases between them. Invoking a phase runs earlier phases in that lifecycle, but actual work depends on plugin goals bound by the packaging and POM. verify runs integration tests only when a plugin such as Failsafe is configured for the relevant phases.
Code Example
mvn compile # visits phases through compile
mvn test # also visits compile and test-compile
mvn package # also visits test, then runs the packaging goal bound for the project type
mvn verify # runs configured goals through verify; integration tests require bindings
mvn install # stores the artifact/POM in the local Maven repository
mvn deploy # publishes to the configured remote deployment repository
For ordinary jar packaging Maven supplies useful default bindings, but a lifecycle phase does not guarantee a particular goal in every project.
Common Mistakes & Pitfalls
- Running phases individually: Freshers often run 'mvn compile' then 'mvn test' then 'mvn package' as three separate commands, not realizing that 'mvn package' visits earlier phases, where configured/default goals compile and test. This wastes time and shows a misunderstanding of how phases work.
- Confusing install with deployment: Many freshers think 'mvn install' deploys their application to a server. It actually just copies the JAR to your local ~/.m2/repository directory so other Maven projects on your machine can use it as a dependency. Deploying to a server is done by tools like Docker or Kubernetes, not Maven install.
- Skipping to package without understanding: Running 'mvn package' without understanding that it's visiting the test phase and running its bound goals unless tests are skipped can be dangerous. If tests fail, the build fails — some freshers then disable tests entirely rather than fixing the failing test, which defeats the purpose of automated testing.
Check your understanding
Answer these without looking back at the article.
- What is the difference between 'mvn install' and 'mvn deploy'?
- How do you skip the test phase?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.