Top Rated Maven Interview Questions
1) What is Maven?
Maven is a project management tool. It is based on POM (Project Object Model). More details…
2) What aspects are managed by Maven?
Builds
Documentation
Reporing
SCMs
Releases
Distribution
3) What are the advantages of Maven?
No need to add jar file in each project
Creates right directory structure
Builds and deploys the project
4) What is the command to check the maven version?
Type the following command on console to know the maven version.
mvn -version
5) What does the build tool?
Generates source code (if auto-generated code is used)
Generates documentation from source code
Compiles source code
Packages compiled code into JAR of ZIP file
Installs the packaged code in local repository, server repository, or central repository
6) What is the difference between Ant and Maven?
Ant
It is a tool box.
It is mainly a build tool.
There is no life cycle.
Ant doesn’t have formal conventions.
Ant is procedural.
Maven
It is a framework.
It is mainly a project management tool.
There is life cycle.
Maven has a convention to place source code, compiled code etc.
Maven is declarative.
The ant scripts are not reusable. The maven plugins are reusable.
7) What is a MOJO?
A MOJO stands for Maven plain Old Java Object. Each MOJO is an executable goal in Maven, and a plugin is a distribution of one or more related MOJOs.
8) What is repository?
A repository is a directory or place where all the jars and pom.xml file are stored.
There are 3 types of repository in Maven:
Local Repository
Central Repository
Remote Repository
9) What is local repository?
Maven local repository is created by maven in your local system when you run any maven command.
10) What is central repository?
Maven central repository is created by maven community on the web.
11) What is remote repository?
Maven remote repository is located on the web by different vendors. So you need to define the dependency in pom.xml file manually. It is important because most of libraries are missing from the central repository.
12) What is POM?
POM stands for Project Object Model. The pom.xml file contains information of project and project configuration.
13) What are the build phases in Maven?
validate
compile
test
package
integration-test
verify
install
deploy
14) What is the command to package maven project?
mvn -package
15) What is fully qualified artifact name of maven project?
- <groupId>:<artifactId>:<version>
16) What is archetype?
Archetype is the maven plugin. It creates the project structure.