Javatpoint Logo
Javatpoint Logo

Maven Interview Question

A list of top frequently asked maven interview questions and answers are given below.

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
  • Reporting
  • SCMs
  • Releases
  • Distribution
More details.

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
More details.

4) What is the command to check the maven version?

Type the following command on console to know the maven version.

More details.

5) What does the build tool?

  • Generates source code (if the auto-generated code is used)
  • Generates documentation from source code
  • Compiles source code
  • Packages compiled code into a JAR or ZIP file
  • Installs the packaged code in the local repository, server repository, or central repository
More details.

6) What is the difference between Ant and Maven?

It is a toolbox.It is a framework.
It is mainly a build tool.It is mainly a project management tool.
There is no life cycle.There is alife cycle.
Ant doesn't have formal conventions.Maven has a convention to place source code, compiled code etc.
Ant is procedural.Maven is declarative.
The ant scripts are not reusable.The Maven plugins are reusable.
More details.

7) Why is the use of the profile required in Maven?

For providing probability to projects, we use profiles.

8) What is the syntax for offline project creation?

The syntax for project creation is:

mvn o packg.

9) How is the propagation of plugins to child POMs stopped?

It can be done using the following syntax:

10) What is the use of the exclusion element?

The element is used to exclude dependencies.

11) Define SNAPSHOT in terms of maven.

The snapshot indicates the current development copy.

12) Define Archetype.

It is a Maven plugin which is designed for the creation of project structure.

7. What does central repository consist of?

It consists of a large number of libraries that are frequently used.

13) Give the command for installation of the JAR file in a local repository.

mvn install

14) Mention the phases of cleaning lifecycle.

The lifecycle of cleaning consist of:

  • pre-clean
  • clean
  • post-clean

15) What is the purpose of mvn clean command?

The command removes the target directory before the starting of a build process.

16) 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.

17) What is a repository?

A repository is a directory or place where all the jars and pom.xml file are stored. There are 3 types of a repository in Maven:

  1. Local Repository
  2. Central Repository
  3. Remote Repository
More details.

18) What is a local repository?

Maven local repository is created by maven in your local system when you run any maven command. More details.

19) What is a central repository?

Maven community creates maven central repository on the web. More details.

20) What is a 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 the libraries are missing from the central repository. More details.

21) What is POM?

POM stands for Project Object Model. The pom.xml file contains information of project and project configuration. More details.

22) What are the build phases in Maven?

  1. validate
  2. compile
  3. test
  4. package
  5. integration-test
  6. verify
  7. install
  8. deploy

23) What is the command to package maven project?

24) What is the fully qualified artifact name of maven project?

25) What is an archetype?

Archetype is the maven plugin. It creates the project structure.

You may also like:

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA