• Home
  • DevOps
  • Top Maven Interview Questions and Answers

Top Maven Interview Questions and Answers

Last updated on Feb 18 2022
Mukul Bose

Table of Contents

Top Maven Interview Questions and Answers

What is Maven?

Maven is a project management and comprehension tool. Maven provides developers a complete build lifecycle framework. The development team is easily able to automate the project’s build infrastructure in almost no time as Maven uses a standard directory layout and a default build lifecycle.

Maven is a popular open-source build tool developed by the Apache Group to build, publish, and deploy several projects. It is written in Java and is used to build projects written in C#, Scala, Ruby, etc.

This tool is used to develop and manage any Java-based project. It simplifies the day-to-day work of Java developers and aids them in their projects.

What are the main features of Maven?

Some of the main features of Maven are:

  • Simple to use: Maven provides easy project settings that are based on genuine practices.
  • Fast: You can receive a fresh project or module that began in fewer seconds in Maven.
  • Easy to learn: Maven usage and commands are pretty easy to learn across all projects. Therefore ramp-up time for new developers coming onto a project is very less.
  • Dependency management: Maven provides superior dependency management including automatic updates and transitive dependencies.
  • Multiple Projects: You can easily work on multiple projects at the same time by using Maven.
  • Huge Library: Maven has a large and growing repository of libraries and metadata to use out of the box.

List the differences between ANT and Maven.

Ant Maven
Ant doesn’t have formal conventions, so we need to provide information about the project structure in the build.xml file. Maven has a convention to place source code, compiled code, etc. So we don’t need to provide information about the project structure in pom.xml file.
Ant is procedural, you need to provide information about what to do and when to do through code. You need to provide order. Maven is declarative, everything you define in the pom.xml file.
There is no life cycle in Ant. There is a life cycle in Maven.
Ant is a toolbox. Maven is a framework.
It is mainly a build tool. It is mainly a project management tool.
The ant scripts are not reusable. The maven plugins are reusable.
It is less preferred than Maven. It is more preferred than Ant.

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

Why should one use Maven?

  • It aids in setting up the project very quickly and it avoids complicated build files like build.xml. the pom.xml file is at the core of Maven.POM.xml is a collection of dependencies of your Java Project which one can specify to Maven. After this Maven will download all of them from the internet and store it to some repository i.e. local repository, central repository, and remote repository.
  • It helps to bundle all the jars in your package i.e. in your War file or Ear file because all of them will be stored in the repository. So next time wherever you install this application that repository will be used for any dependencies lookup. In this way, your deployment file will be very light.

Mention the steps for installing Maven on windows.

Maven can be downloaded and installed on windows, linux, and MAC OS platforms. To install Maven on windows, you need to perform the following steps:

    • Download Maven and extract it.
    • Add JAVA_HOME and MAVEN_HOME in the list of environment variables.
    • Add the environment path in Maven variable.
    • The last step is the verification of Maven by checking its version.

What does it mean when you say Maven uses Convention over Configuration?

    • In the case of Configuration, developers have to create the build processes manually and they have to specify each and every configuration in detail. But, Maven uses convention where the developers need not create the build processes manually.
    • Also, for convention, users do not need to specify the configuration in detail. Once a developer creates a project in Maven then Maven will automatically create a structure. Developers just have to place the files appropriately. There is no need to specify any configuration details in pom.xml file.

What is a project’s fully qualified artifact name?

<groupId>:<artifactId>:<version>

If you fail to define any information, where does your pom inherits that information from?

All POMs are inherited from a parent despite explicitly defined or not. This base POM is called Super POM and it contains values that are inherited by default.

How profiles are specified in Maven?

Profiles are specified by making use of a subset of the elements that are available in the POM itself.

What are the elements in POM that a profile can freely modify when specified in the POM?

<repositories>, <pluginRepositories>,<dependencies>, <plugins> ,<properties>, <modules><reporting>,<dependencyManagement>,<distributionManagement>

What are the benefit of storing JARS/external dependencies in the local repository instead of a remote one?

It uses less storage and also makes checking out a project quicker, without the need for versioning the JAR files.

What is a system dependency?

Dependency with scope system is always available and is not looked up in the repository, they are usually used to tell Maven about dependencies that are provided by the JDK or the VM. Thus, system dependencies are especially useful for resolving dependencies on artifacts that JDK normally provides.

What is the use of optional dependency?

You can mark any transitive dependency as optional using the “optional” element. As an example, A depends upon B and B depends upon C. Now B marked C as optional. Then A will not use C.

What is dependency exclusion?

You can exclude any transitive dependency using the “exclusion” element. Suppose if A depends upon B and B depends upon C then A can be marked C as excluded.

How to run the clean plugin automatically during the build?

For this, you just need to place the clean plugin inside the execution tag in pom.xml file.

What is the meaning of the message “You cannot have two plugin executions with the same or missing elements”?

It simply means that you have executed a plugin multiple times with the same <id>. To correct this you just need to provide each <execution> with a unique <id>.

What aspects are managed by Maven?

  • Builds
  • Documentation
  • Reporting
  • SCMs
  • Releases
  • Distribution

What are the advantages of Maven?

  • No need to add jar file in each project
  • Creates right directory structure
  • Builds and deploys the project

What are the aspects Maven manages?

Maven provides developers ways to manage following −

    • Builds
    • Documentation
    • Reporting
    • Dependencies
    • SCMs
    • Releases
    • Distribution
    • mailing list

How do you know the version of mvn you are using?

Type the following command – mvn -version

What is POM?

POM stands for Project Object Model. In Maven, it is a fundamental Unit of Work and it is an XML file. You can find it in the base directory of the project. It consists of information about the project and various configuration details used by Maven to build the project(s).

Project Object Model (POM) refers to the XML files with all the information regarding project and configuration details.

  • It has the description of the project, information regarding the versioning and configuration management of the project.
  • The XML file is in the project home directory. When we tend to execute a task, Maven searches for the POM in the current directory.

What information does POM contain?

POM contains the following configuration information −

  • project dependencies
  • plugins
  • goals
  • build profiles
  • project version
  • developers
  • mailing list

What is Maven artifact?

  • An artifact is a file, normally a JAR that gets deployed to a Maven repository. A Maven build creates one or more artifacts, such as a compiled JAR and a source JAR.
  • Each artifact consists of a group ID, an artifact ID, and a version string. The three together uniquely identify the artifact. A project’s dependencies are specified as artifacts.

What is the Maven Build lifecycle?

A Build Lifecycle can be defined as a well-defined sequence of phases. It clearly defines the order in which the goals are to be executed. Each build phase contains a sequence of goals. If one life cycle is executed, all build phases in that life cycle are executed. If a build phase is executed, all build phases before it in the pre-defined sequence of build phases are executed.

Name the -build lifecycle of Maven.

The three build lifecycles are −

clean: cleans up artifacts created by prior builds.

default: used to build the application.

site: generates site documentation for the project.

What is the command to build your Maven site?

Type the command − mvn site

What would the command mvn clean do?

This command deletes the target directory with all the build data before starting the build process.

What are the different phases of a Maven Build Lifecycle?

Following are the phases of Maven build lifecycle −

validate − validate the project and check if everything is correct and all necessary information is available.

compile − this phase compiles the source code of your project.

test − tests the compiled source code by using a suitable unit testing framework. These tests should not require the code to be packaged or deployed

package − takes the compiled code and packages it in its distributable format.

integration-test − processes and deploys the package if possible into an environment where integration tests can be run.

verify − runs any checks to verify the package is valid and meets the required quality criteria.

install − installation of the package into the local repository. This is done to use it as a dependency in other projects locally.

deploy − done in an integration environment or release environment. Here the final package is copied to the remote repository for sharing with other developers and projects.

What is a goal in Maven terminology?

A goal represents a specific task that contributes to the building and managing of a project. It is bound to zero or more build phases. A goal that is not bound to any build phase could be executed outside of the build lifecycle by invocating it directly.

What would the command mvn clean dependency:copy-dependencies package do?

This command will clean the project, copy the dependencies and package the project (executing all phases up to package).

What phases does a Clean Lifecycle consist of?

The clean lifecycle consists of the following phases −

pre-clean

clean

post-clean

What phases does a Site Lifecycle consist of?

The phases in Site Lifecycle are −

pre-site

site

post-site

site-deploy

What is Build Profile?

A Build profile is a set of configuration values that can be used to set or override default values of Maven build. Using a build profile, you can customize build for different environments such as Production and the Development environments.

What are different types of Build Profiles?

Build profiles are of three types −

Per Project − Defined in the project pom.xml file.

Per-User − Defined in Maven settings XML file &#;%USER_HOME%/.m/settings.xml&#;

Global −Defined in Maven global settings xml file &#;%M_HOME%/conf/settings.xml&#;

How can you activate profiles?

A Maven Build Profile can be activated in the following ways −

  • Explicitly using command console input.
  • Through maven settings.
  • Based on environment variables (User/System variables).
  • OS Settings (for example, Windows family).
  • Present/missing files.

What types of Maven repository?

Maven repositories are of three types –

Local: Maven local repository is a folder location that is present on your machine. It is created when you run any maven command for the first time. Maven local repository is a location where you can find your project’s all dependencies (library jars, plugin jars etc).

Central: It is a repository provided by the Maven community. It contains a huge collection of commonly used libraries. When Maven does not find any dependency in local repository, it starts searching in central repository using the following URL: http://repo.maven.org/maven/.

Remote: Sometimes, Maven is not able to find a mentioned dependency in the central repository as well then it stops the build process and an output error message is displayed on the console. To avoid such a situation, Maven provides the idea of Remote Repository which is nothing but the developer’s own custom repository containing required libraries or other project jars.

Can you tell me the default location of your local repository?

~/m./repository.

Tell me the command to install JAR file in local repository.

mvn install

Is there a particular sequence in which Maven searches for dependency libraries?

Following is the search pattern –

  • Search for dependency in the local repository, if not found, move to step else do the further processing.
  • Search for dependency in the central repository first, if not found and the remote repository is mentioned then move to step else it is downloaded to the local repository for future reference.
  • If a remote repository has not been mentioned, Maven simply stops the processing and throws an error (Unable to find dependency).
  • Search for dependency in the remote repository first, if found it is downloaded to the local repository for future reference otherwise Maven is expected to stop processing and throws an error.

What are the uses of Maven Plugins?

Maven Plugins are used to −

  • create jar file.
  • create war file.
  • compile code files.
  • unit testing of code.
  • create project documentation.
  • create project reports.

What are the types of Maven Plugins?

Maven provides the following two types of Plugins −

Build plugins −They come into picture during the build and should be configured in the <build/> element of pom.xml

Reporting plugins −They get executed during the site generation and they should be configured in the <reporting/> element of the pom.xml

When does Maven use the External Dependency concept?

Maven dependency management uses the concept of Maven Repositories (Local, Central, Remote). Suppose dependency is not present in any of remote repositories and central repository then in such case Maven uses the concept of External Dependency.

What are the things that you must define for each external dependency?

External dependencies (library jar location) can be configured in pom.xml in same way as other dependencies are configured.

  • First, specify groupId the same as the name of the library.
  • Then specify artifactId the same as the name of the library.
  • Thirdly, specify scope as a system.
  • Lastly, specify the system path relative to the project location.

What is Archetype?

An archetype is a Maven plugin whose task is to create a project structure as per its template.

What is SNAPSHOT in Maven?

SNAPSHOT can be defined as a special version that indicates a current development copy. Unlike the regular versions, Maven checks for a new SNAPSHOT version in its remote repository. Maven does it for every build.

What is the difference between Snapshot and Version?

  • In the case of Version, if Maven once downloads the mentioned version say data-service:., it will never try to download a newer . available in the repository. To download the updated code, the data-service version is then upgraded to ..
  • In the case of SNAPSHOT, Maven will automatically fetch the latest SNAPSHOT (data-service:.-SNAPSHOT) every time the team builds its project.

What is a transitive dependency in Maven?

Transitive dependency is nothing but to avoid the need to discover and specify the libraries that your own dependencies require, and including them automatically.

What does dependency management mean with respect to transitive dependency?

It simply means to directly specify the versions of artifacts to be used when they are encountered in transitive dependencies. For example, project C can include B as a dependency in its dependency Management section and directly control which version of B is to be used when it is ever referenced.

How Maven handles and determines what version of dependency will be used when multiple versions of an artifact are found?

If you find two dependency versions at the same depth in the dependency tree, then you use the first declared dependency. This is nothing but dependency mediation.

What is the dependency scope? Name all the dependency scope.

Dependency scope typically includes dependencies as per the current stage of the build. The various Dependency scopes are −

compile − This scope indicates that dependency is available in the classpath of the project. It is the default scope.

provided − This indicates that the dependency is to be provided by JDK or web-Server/Container at runtime.

runtime − This scope tells that you don’t need dependency is for compilation but you need it for for execution.

test − This scope states that the dependency is only available for the test compilation and execution phases.

system − This scope indicates that you must provide the system path.

import − This scope is only used when the dependency is of type pom. This scope tells that the specified POM should be replaced with the dependencies in the POM’s <dependency Management> section.

What is the minimal set of information for matching dependency reference against a dependency Management section?

{groupId,artifactId,type,classifier}.

Is it possible to refer a property defined in your pom.xml file?

  • To refer a property that is defined in your pom.xml, the property name uses the names of the XML elements that define the value, with “pom” being allowed as an alias for the project element i.e root.
  • So ${pom.name} points to the name of the project, ${pom.version} refers to the project version, ${pom.build.finalName} refers to the final name of the file created during the built project packaging etc.

What are the default values for the packaging element? If there is no packaging element defined? What is the default value for that?

The valid packaging values include jar, war, ear, and pom. If no packaging value has been specified, then by default it will be a jar.

What is the use of the execution element in pom file?

The <execution> element contains the information required for the execution of a plugin.

What is the command to check the maven version?

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

  1. mvn -version

What is the difference between Ant and Maven?

Ant 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.

 

Why is the use of the profile required in Maven?

For providing probability to projects, we use profiles.

What is the syntax for offline project creation?

The syntax for project creation is:

mvn o packg.

How is the propagation of plugins to child POMs stopped?

It can be done using the following syntax:

set <inherited> to false.

What is the use of the exclusion element?

The element is used to exclude dependencies.

Define SNAPSHOT in terms of maven.

The snapshot indicates the current development copy.

Define Archetype.

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

What does central repository consist of?

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

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

mvn install

Mention the phases of cleaning lifecycle.

The lifecycle of cleaning consist of:

  • pre-clean
  • clean
  • post-clean

What is the purpose of mvn clean command?

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

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.

What is a repository?

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

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

What is a local repository?

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

What is a central repository?

Maven community creates maven central repository on the web.

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.

What are the build phases in Maven?

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

What is the command to package maven project?

  1. mvn -package

What is the fully qualified artifact name of maven project?

  1. <groupId>:<artifactId>:<version>

What is an archetype?

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

What does Maven help with?

Maven helps with the following:

  • Apache Maven helps manage all the processes, such as building, documentation, releasing, and distribution in project management.
  • The tool simplifies the process of project building. It increases the performance of the project and the building process.
  • The task of downloading JAR files and other dependencies is done automatically.
  • Maven provides easy access to all the required information.
  • Maven makes it easy for the developer to build a project in different environments, without worrying about the dependencies, processes, etc.
  • In Maven, it is simple to add new dependencies, all you need to do is to write the dependency code in the pom file.

What are the different elements that Maven takes care of?

In the process, it takes care of the following:

  • Builds
  • Dependencies
  • Reports
  • Distribution
  • Releases
  • Mailing list

What is POM?

Project Object Model (POM) refers to the XML files with all the information regarding project and configuration details.

  • It has the description of the project, information regarding the versioning and configuration management of the project.
  • The XML file is in the project home directory. When we tend to execute a task, Maven searches for the POM in the current directory.

What are the minimum required elements for POM?

The minimum required elements for POM are:

  • project root
  • modelVersion – should be ..
  • groupId – project’s group id
  • artifactId – artifact (project) id
  • version – version of the artifact

What is meant by the term ‘Build Tool’?

A build tool is essential for the process of building. It is needed for the following procedures:

  • Generating source code.
  • Generating documentation from the source code.
  • Compiling of source code.
  • Packaging of the compiled codes into JAR files.
  • Installing the packaged code in a local repository, server, or central repository.

What are the steps to install Maven on Windows?

To install Maven on Windows, observe the following steps:

  • Download Maven first, and then extract it.
  • In the environment variable, add JAVA_HOME, and MAVEN_HOME.
  • Then, add the environment path in the Maven variable.
  • Lastly, verify the Maven installation by checking its version. The command mvn -version will display the version installed in the system.

What are the steps to install Maven on Ubuntu?

To install Maven on to Ubuntu, observe the following steps:

  • The primary step is to install Java.
  • Then, download Maven.
  • Configure environment variables JAVA_HOME, M_HOME, MAVEN_HOME, and PATH.
  • Lastly, verify the Maven installation by checking its version.

What is the command to install JAR files in the Local Repository?

  • mvn install is used to install JAR files in the local repository.
  • To install the JAR manually into the local Maven repository, the following plugin is used: mvn install:install-file-Dfile=<path to file>.

How do you know the version of Maven being used?

  • mvn –version is used to check the version of Maven present in the system.
  • The command is typed in the command prompt, and the version of Maven in the system will eventually appear on the screen.

a1 2

What is Maven Build Lifecycle?

Maven lifecycle is a collection of steps that are to be followed, to build a project. There are three built-in build lifecycles:

  • Default: Handles project deployment.
  • Clean: Handles project cleaning.
  • Site: Handles the creation of the project site’s documentation.

What are the different phases in the Maven Build Lifecycle?

Build Lifecycle has different build phases or stages, which are below:

a2 2

Which command is used to build a Maven site?

  • – mvn site command is used to build a Maven site
  • The resulting site, by default, is target/site/…

What are the different conventions used while naming a project in Maven?

The full name of a project in Maven includes:

<GroupId>: <artifactId>: <version>

For example:

org.apache.maven: maven: ..

What is a Maven Artifact?

Maven Artifact refers to a file, usually a JAR that gets deployed to a Maven repository. The tool creates one or more artifacts, such as a compiled JAR and a source JAR.

Every artifact has its groupID, an artifact ID, and a version string. These three together identify the artifact. For example:

com.your.package, any name, and a version string (to uniquely identify).

What are the phases of a Clean Life Cycle?

The phases of a clean life cycle include:

  • Pre-clean
  • Clean
  • Post-clean

What are the phases of a Site Life Cycle?

The phases of a site life cycle include:

  • Pre-site
  • Site
  • Post-site
  • Site-deploy

What is meant by Maven Plugins?

  • Maven plugins are essential features of Maven that are used to reuse the common build logic across several projects.
  • The plugins are needed to carry out tasks like compiling code, testing them, creating JAR files, and documenting the projects.

Why are Maven Plugins used?

Maven Plugins are used to:

  • Create a JAR file.
  • Create a WAR file.
  • Compile code files.
  • Unit testing of code.
  • Create project documentation.
  • Create project reports.

What is the difference between Convention and Configuration in Maven?

Convention  Configuration
  • The convention is when the developers are not required to create the build processes.
  • The users do not have to specify the configuration in detail, and once the project is created it will automatically create a structure.
  • The configuration is when developers are supposed to create the build processes manually.
  • They must specify every configuration in detail.

Why is it said that “Maven uses convention over configuration”?

  • Maven uses convention instead of configuration, due to the fact that the developers only need to create a Maven project. The rest of the structure is automatically created.
  • There are many conventions present in Maven for setting up a project, building the artifacts, releasing the code, and running unit tests.

What is Maven’s order of inheritance?

The order of inheritance in Maven is:

  • Settings
  • CLI parameters
  • Parent POM
  • Project POM

What is Clean, Default, and Site in Maven?

There are three built-in build life cycles:

  • Clean: The clean lifecycle looks after project cleaning.
  • Default: The default lifecycle handles the project deployment.
  • Site: The site lifecycle refers to the creation of the project’s site documentation.

What is a Maven Repository?

Maven repositories refer to the directories of packaged JAR files that contain metadata. The metadata refers to the POM files relevant to each project. This metadata is what allows Maven to download dependencies.

There are three types of repositories:

  • Local Repository
  • Remote Repository
  • Central Repository

What are the different types of Maven Repositories?

There are three types of Maven repositories:

. Local Repository: 

  • Local repository refers to the machine of the developer where all the project material is saved.
  • The local repository contains all the dependency jars.

. Remote Repository:

  • The remote repository refers to the repository present on a server that is used when Maven needs to download dependencies.
  • Whenever anything is required from the remote repository, it is first downloaded to the local repository, and then it is used.

. Central Repository:

  • Central repository refers to the Maven community that comes into action when there is a need for dependencies, and those dependencies cannot be found in the local repository.
  • Maven downloads the dependencies from here in the local repository whenever needed.

How does Maven Architecture work?

Maven architecture works in three steps, which are as follows:

  • The first step is to read the pom.xml file.
  • Then, it downloads the dependencies defined in pom.xml into the local repository from the central repository.
  • Lastly, it creates and generates a report according to the requirements, and executes life-cycles, phases, goals, plugins, etc.

a3 3

What do Build Life Cycles and phases imply in the basic concepts of Maven?

  • Build Life Cycles consist of a sequence of build phases, and each build phase consists of a series of goals.
  • When a stage is run, all the purposes related to that phase, and its plugins are also compiled.

What is the ‘Goal’ in the Maven terminology?

  • The term goal refers to a specific task that makes it possible for the project to be built and organized.
  • Phases that are a stage in the life cycle define the sequence in which the desired goals are to be accomplished.

What is meant by the term ‘Dependencies and Repositories’ in Maven?

  • Dependencies refer to the Java libraries that are needed for the project. Repositories refer to the directories of packaged JAR files.
  • If the dependencies are not present in your local repository; then Maven downloads them from a central repository and stores them in the local repository.

What is a ‘Snapshot’ in Maven?

Snapshot refers to the version available in the Maven remote repository. It signals the latest development copy. Maven inspects for a new version of Snapshot in the remote repository, for every new build.

The snapshot is updated by the data service team with an updated source code every time to the repository for each Maven build.

What types of projects are available in Maven?

  • There are thousands of Java projects provided as templates by Maven.
  • This helps the user, as they no longer have to remember every configuration to set up a particular project.
  • For example Spring Project, Spring MVC, Spring Boot, etc.

What is a Maven Archetype?

  • Maven Archetype refers to a Maven plugin entitled to create a project structure as per its template.
  • These archetypes are just project templates that are generated by Maven when any new project is created.

What does ‘Maven Clean’ imply?

  • Maven clean is a plugin as the name suggests, that approaches to clean the files and directories generated by Maven at the time of its build.
  • The plugin removes the target folder that contains all the class files, docs, JAR files.

What is a Build Profile?

  • Build profiles refer to the set of configuration values required to build a project using different configurations.
  • Different build profiles are added to the POM files while enabling different builds.
  • A build profile helps in customizing build for different environments.

What are the different types of Build Profiles?

There are three different types of build profiles:

  • Per Project – defined in pom.xml
  • Per – User – defined in Maven settings.xml
  • Global – defined in Maven global settings.xml

What is meant by the term ‘System Dependency’?

System dependency refers to the dependency that is present with the scope system. These dependencies are commonly used to help Maven know the dependencies that are provided by the JDK or VM.

System dependencies are mostly used to resolve dependencies on artifacts that are provided by the JDK.

What is the reason for using an Optional Dependency?

  • Optional dependencies are used to decrease the transitive burden of some libraries.
  • These dependencies are used when it is not feasible to divide a project into sub-modules.
  • Some dependencies are only used for a specific feature in the project, and if that feature is not there, then that dependency will not be used.

What is the ‘Dependency Scope’, and how many types of Dependency Scopes are there?

Dependency scope refers to all the dependencies about the current stage of the build.

The different types of dependency scopes are:

  • Compile
  • Provided
  • Runtime
  • Test
  • System
  • Import

What is meant by ‘Transitive Dependency’ in Maven?

  • Maven avoids the need to find out and specify libraries that the dependencies require, by including transitive dependencies automatically.
  • Transitive dependency says that if X depends on Y and Y depends on Z, then X depends on both Y and Z.

How can a Maven Build Profile be activated?

A Maven build profile may be activated in the following ways:

  • Explicitly using command console input.
  • Through Maven settings.
  • Based on environment variables.
  • OS Settings.
  • Present/missing files.

What is meant by ‘Dependency Exclusion’?

The exclusion element is used to exclude any transitive dependency. The concept says if X depends on Y and Y depends on Z, then X can be marked Z as excluded.

What is MOJO?

MOJO can be defined as a Maven plain Old Java Object. Every MOJO is an executable goal in Maven, and a plugin refers to the distribution of such MOJOs. MOJO enables Maven to extend the functionality that is already not found in it.

What is the command to produce a new project based on a hard drive?

  • -mvn archetype: create is used to create a new project.
  • The archetype is created after reading the source and resource file, the values of its parameters, and other properties.

What is the Maven settings.xml file?

The Maven settings.xml file contains elements used to define the values needed to configure Maven execution differently.

It contains the following configurations:

  • Proxy configuration
  • Local repository configuration
  • Remote repository configuration
  • Central repository configuration

What is meant by the term ‘Super POM’?

Super POM refers to the default POM of Maven. The POMs of Maven can be derived from a parent or by default. To execute any particular objectives, effective POM is used.

Super POM supports the developers to configure the pom.xml file with the least configurations.

Where are Maven dependencies stored?

  • All the JARS, dependency files, etc. that are downloaded by Maven are saved in the Maven local repository.
  • The Maven local repository is a folder location on the local system where all the artifacts are locally stored.

So, this brings us to the end of the Maven Interview Questions blog.
This Tecklearn ‘Top Maven Interview Questions and Answers’ helps you with commonly asked questions if you are looking out for a job in Maven or DevOps Domain. If you wish to learn Maven and build a career in DevOps domain, then check out our interactive Maven Training, that comes with 24*7 support to guide you throughout your learning period.

https://www.tecklearn.com/course/maven/

Maven Training

About the Course

Tecklearn has specially designed this Maven Training Course to advance your skills for a successful career in this domain. The course will cover different components of Maven and how they are used in software development operations.  You will get an in-depth knowledge of these concepts and will be able to work on related demos. Upon completion of this online training, you will hold a solid understanding and hands-on experience with Maven.

Why Should you take Maven Training?

  • The average salary for “ant maven” ranges from approximately $71,430 per year for Entry Level Engineer to $126,916  per year for Development Operations Engineer. – Indeed.com
  • According to Grand View Research, the DevOps market size is estimated to be worth $12.85 billion by 2025. DevOps professionals are highly paid and in-demand throughout industries including retail, eCommerce, finance, and technology.

What you will Learn in this Course?

Introduction to DevOps

  • What is Software Development
  • Software Development Life Cycle
  • Why DevOps?
  • What is DevOps?
  • DevOps Lifecycle
  • DevOps Tools
  • Benefits of DevOps
  • How DevOps is related to Agile Delivery
  • DevOps Implementation

Maven

  • Maven
  • Maven Directory
  • Maven Lifecycle
  • Maven Dependencies
  • Maven Repositories
  • Phases and Goals

Got a question for us? Please mention it in the comments section and we will get back to you.

 

0 responses on "Top Maven Interview Questions and Answers"

Leave a Message

Your email address will not be published. Required fields are marked *