Interview Questions.

Top 100+ Maven Interview Questions And Answers

fluid

Top 100+ Maven Interview Questions And Answers

Question 1. What Is Maven?

Answer :

Maven is a task control and comprehension tool. Maven offers builders a entire construct lifecycle framework. Development team can automate the challenge's build infrastructure in nearly no time as Maven uses a wellknown directory format and a default build lifecycle.

Question 2. What Does It Mean When You Say Maven Uses Convention Over Configuration?

Answer :

Maven makes use of Convention over Configuration this means that developers aren't required to create construct method themselves. Developers do no longer have to mention each and each configuration info.

Java Script Interview Questions
Question 3. What Are The Aspects Maven Managed?

Answer :

Maven presents builders ways to control following:

Builds
Documentation
Reporting
Dependencies
SCMs
Releases
Distribution
mailing listing
Question four. How Do You Know The Version Of Mvn You Are Using?

Answer :

Type the subsequent command :

mvn --model

Java Script Tutorial
Question five. What Is Pom?

Answer :

POM stands for Project Object Model. It is fundamental Unit of Work in Maven. It is an XML report. It usually is living within the base listing of the assignment as pom.Xml. It incorporates information approximately the task and numerous configuration details utilized by Maven to construct the project(s).

Adv Java Interview Questions
Question 6. What Information Does Pom Contain?

Answer :

POM includes the some of the following configuration facts −

mission dependencies.
Plugins.
Dreams.
Construct profiles.
Venture model.
Builders.
Mailing list.
Question 7. What Is Maven Artifact?

Answer :

An artifact is a report, normally a JAR that receives deployed to a Maven repository. A Maven build produces one or extra artifacts, which include a compiled JAR and a "resources" JAR.

Each artifact has a group ID (usually a reversed area name, like com.Instance.Foo), an artifact ID (just a call), and a version string. The three together uniquely pick out the artifact. A mission's dependencies are distinct as artifacts.

Adv Java Tutorial Core Java Interview Questions
Question eight. Name The three Build Lifecycle Of Maven?

Answer :

The three build lifecycles are:

smooth:cleans up artifacts created by previous builds.
Default (or build):This is used to build the application.
Site: generates website online documentation for the task.
Question nine. What Is Maven Build Lifecycle?

Answer :

A Build Lifecycle is a well defined sequence of stages which define the order in which the goals are to be completed. Here phase represents a stage in existence cycle.

Java Interview Questions
Question 10. What Is The Command To Quickly Build Your Maven Site?

Answer :

Type the command− mvn site

Core Java Tutorial
Question 11. What Would The Command Mvn Clean Do ?

Answer :

This command removes the goal directory with all of the build records earlier than starting the build technique.

Javascript Objects Interview Questions
Question 12. What Are The Phases Of A Maven Build Lifecycle?

Answer :

Following are the phases:−

validate − validate the undertaking is accurate and all essential information is to be had.
Assemble − compile the source code of the challenge.
Test − test the compiled source code the usage of a suitable unit checking out framework. These assessments should now not require the code be packaged or deployed
bundle − take the compiled code and package it in its distributable layout, such as a JAR.
Integration-take a look at − method and install the bundle if necessary into an environment where integration exams can be run.
Verify − run any tests to verify the package deal is legitimate and meets first-rate standards.
Set up − installation the package deal into the local repository, to be used as a dependency in other tasks locally.
Set up − finished in an integration or release surroundings, copies the final package to the far flung repository for sharing with different developers and tasks.
Java Script Interview Questions
Question thirteen. What Is A Goal In Maven Terminology?

Answer :

A purpose represents a selected task which contributes to the building and handling of a task. It may be certain to 0 or more build phases. A goal no longer sure to any construct section can be done out of doors of the build lifecycle through direct invocation.

Java Tutorial
Question 14. What Would This Command Do Mvn Clean Dependency:copy-dependencies Package?

Answer :

This command will smooth the assignment, replica the dependencies and bundle the project (executing all levels up to bundle).

Question 15. What Phases Does A Clean Lifecycle Consist?

Answer :

The easy lifecycle includes the following levels:

pre-clean.
Smooth.
Submit-easy.
Javascript Advanced Interview Questions
Question sixteen. What Phases Does A Site Lifecycle Consist?

Answer :

The stages in Site Lifecycle are:−

pre-web page
web page
put up-web site
web page-installation
Javascript Objects Tutorial
Question 17. What Is Build Profile?

Answer :

A Build profile is a set of configuration values which may be used to set or override default values of Maven build. Using a construct profile, you can customize construct for extraordinary environments such as Production v/s Development environments.

Jenkins Interview Questions
Question 18. What Are Different Types Of Build Profiles?

Answer :

Build profiles are of three types :

Per Project − Defined inside the challenge POM record, pom.Xml.
Per User − Defined in Maven settings xml file (%USER_HOME%/.M2/settings.Xml).
Global − Defined in Maven worldwide settings xml report (%M2_HOME%/conf/settings.Xml)
Adv Java Interview Questions
Question 19. How Can You Activate Profiles?

Answer :

A Maven Build Profile can be activated in various approaches −

Explicitly using command console input.
Through maven settings.
Based on environment variables (User/System variables).
OS Settings (as an example, Windows family).
Present/lacking files.
Javascript Advanced Tutorial
Question 20. What Is A Maven Repository?

Answer :

A repository is a place i.E. Listing where all the challenge jars, library jar, plugins or every other task precise artifacts are stored and can be utilized by Maven effortlessly.

Java collections framework Interview Questions
Question 21. What Types Of Maven Repository?

Answer :

Maven repository are of 3 sorts:

local
principal
far off
Question 22. What Is Local Repository?

Answer :

Maven neighborhood repository is a folder vicinity to your system. It receives created while you run any maven command for the primary time. Maven neighborhood repository keeps your mission's all dependencies (library jars, plugin jars etc).

Maven Tutorial
Question 23. What Is The Default Location For Your Local Repository?

Answer :

~/m2./repository.

JUnit Interview Questions
Question 24. What Is The Command To Install Jar File In Local Repository?

Answer :

mvn install.

Core Java Interview Questions
Question 25. What Is Central Repository?

Answer :

It is repository supplied by means of Maven network. It includes a huge variety of commonly used libraries. When Maven does now not discover any dependency in local repository, it starts offevolved searching in critical repository using following URL: http://repo1.Maven.Org/maven2/.

Jenkins Tutorial
Question 26. What Is Remote Repository?

Answer :

Sometimes, Maven does no longer discover a mentioned dependency in valuable repository as properly then it stops the construct process and output errors message to console. To save you such situation, Maven presents concept of Remote Repository which is developer's very own custom repository containing required libraries or other task jars.

Java eight Interview Questions
Question 27. What Is The Sequence In Which Maven Searches For Dependency Libraries?

Answer :

Following is the quest sample:

Step 1 − Search dependency in local repository, if not determined, circulate to step 2 else if found then do the in addition processing.

Step 2 − Search dependency in relevant repository, if now not determined and far off repository/repositories is/are cited then circulate to step 4 else if determined, then it's far downloaded to nearby repository for destiny reference.

Step 3 − If a remote repository has no longer been noted, Maven genuinely stops the processing and throws mistakes (Unable to locate dependency).

Step 4 − Search dependency in far off repository or repositories, if determined then it's far downloaded to nearby repository for destiny reference in any other case Maven as anticipated prevent processing and throws mistakes (Unable to find dependency).

Java Interview Questions
Question 28. Why Are Maven Plugins Used?

Answer :

Maven Plugins are used to:

create jar record.
Create struggle record.
Compile code documents.
Unit testing of code
create project documentation.
Create task reports.
JUnit Tutorial
Question 29. What Are The Types Of Maven Plugins?

Answer :

Maven affords following two varieties of Plugins:

Build plugins:They execute throughout the construct and must be configured inside the element of pom.Xml
Reporting plugins:They execute for the duration of the website era and they need to be configured within the element of the pom.Xml
Apache Ant Interview Questions
Question 30. When Does Maven Use External Dependency Concept?

Answer :

Maven dependency management the use of idea of Maven Repositories (Local, Central, Remote). Suppose dependency isn't always to be had in any of far off repositories and relevant repository; in such scenarios Maven makes use of concept of External Dependency.

Question 31. What Are The Things You Need To Define For Each External Dependency?

Answer :

External dependencies (library jar place) may be configured in pom.Xml in equal manner as different dependencies.

Specify groupId equal as call of the library.
Specify artifactId equal as name of the library.
Specify scope as gadget.
Specify device route relative to undertaking place.
Java eight Tutorial
Question 32. What Is Archetype?

Answer :

Archetype is a Maven plugin whose undertaking is to create a undertaking shape as per its template.

Svn Subversion Interview Questions
Question 33. What Is The Command To Create A New Project Based On An Archetype?

Answer :

Type the subsequent command: mvn archetype:generate

Javascript Objects Interview Questions
Question 34. What Is Snapshot In Maven?

Answer :

SNAPSHOT is a unique version that shows a present day development copy. Unlike normal variations, Maven assessments for a new SNAPSHOT version in a faraway repository for each build.

Question 35. What Is Difference Between Snapshot And Version?

Answer :

In case of Version, if Maven as soon as downloaded the cited version say facts-provider:1.Zero, it'll by no means try to down load a newer 1.0 to be had in repository. To down load the up to date code, records-provider model is be upgraded to at least one.1.
In case of SNAPSHOT, Maven will automatically fetch the today's SNAPSHOT (facts-provider:1.0-SNAPSHOT) everytime app-ui crew construct their assignment.

Question 36. What Is Transitive Dependency In Maven?

Answer :

Transitive dependency manner to keep away from desiring to discover and specify the libraries that your own dependencies require, and inclusive of them routinely.

Javascript Advanced Interview Questions
Question 37. What Does Dependency Management Mean In The Context Of Transitive Dependency?

Answer :

It manner to at once specify the versions of artifacts for use when they're encountered in transitive dependencies. For an example undertaking C can include B as a dependency in its dependencyManagement segment and without delay control which model of B is for use whilst it is ever referenced.

Question 38. How Maven Handles And Determines What Version Of Dependency Will Be Used When Multiple Version Of An Artifact Are Encountered?

Answer :

Maven determines what model of a dependency is for use whilst a couple of variations of an artifact are encountered. If two dependency variations are at the identical depth within the dependency tree, the primary declared dependency may be used. This is referred to as dependency mediation.

Question 39. What Is Dependency Scope? Name All The Dependency Scope.?

Answer :

Dependency scope consists of dependencies as in line with the present day level of the construct. Various Dependency Scopes are −

compile − This scope suggests that dependency is to be had in classpath of undertaking. It is default scope.
Supplied − This scope indicates that dependency is to be supplied through JDK or net-Server/Container at runtime.
Runtime − This scope indicates that dependency is not required for compilation, however is required during execution.
Take a look at − This scope shows that the dependency is only available for the check compilation and execution stages.
System − This scope suggests that you need to provide the system direction.
Import − This scope is only used while dependency is of type pom. This scope shows that the specified POM need to get replaced with the dependencies in that POM's phase.
Question forty. What Is The Minimal Set Of Information For Matching A Dependency References Against A Dependencymanagement Section ?

Answer :

groupId,artifactId,kind,classifier.

Jenkins Interview Questions
Question forty one. How Do You Reference A Property Defined In Your Pom.Xml File?

Answer :

To reference a property described for your pom.Xml, the belongings name uses the names of the XML elements that define the price, with "pom" being allowed as an alias for the challenge (root) element.

So $pom.Call refers back to the call of the task, $pom.Model refers to the version of the mission, $pom.Construct.FinalName refers to the final name of the record created when the built project is packaged, and so forth.

Question forty two. What Are The Default Values For Packaging Element? If There Is No Packaging Element Defined? What Is The Default Value For That?

Answer :

Some of the legitimate packaging values are jar, battle, ear and pom. If no packaging cost has been specific, it'll default to jar.

Java collections framework Interview Questions
Question forty three. What Is The Value For Packaging Element In Pom For A Project That Is Purely Meta-statistics?

Answer :

pom.

Question forty four. What Is The Use Of Execution Element In Pom File?

Answer :

The <execution> detail carries records's required for the execution of a plugin.

Question 45. What Is A Project's Fully Qualified Artifact Name?

Answer :

<groupId>:<artifactId>:<version>

Question forty six. If You Do Not Define Any Information, Where Does Your Pom Inherits That Information From?

Answer :

All POMs inherit from a determine (in spite of explicitly defined or now not). This base POM is called the Super POM, and contains values inherited by using default.

Question forty seven. How Profiles Are Specified In Maven?

Answer :

Profiles are unique using a subset of the elements to be had in the POM itself.

Question 48. What Are The Elements In Pom That A Profile Can Modify When Specified In The Pom?

Answer :

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

Question forty nine. Why Profile Is Used In Maven?

Answer :

To deliver portability to initiatives ( e.G. Windows, linux etc).

Question 50. What Are The Benefit Of Storing Jars/external Dependencies In Local Repository Instead Of Remote One?

Answer :

It makes use of less storage, it makes sorting out venture faster, non need for versioning JAR files.

Question fifty one. How Can You Build Your Project Offline?

Answer :

Use the command: mvn o package deal.

Question fifty two. How Do You Exclude Dependency?

Answer :

Using the exclusion element.

Question fifty three. What Is A System Dependency?

Answer :

Dependency with scope gadget are continually available and are not seemed up in repository, they're usually used to inform Maven approximately dependencies that are provided by the JDK or the VM. Thus, system dependencies are in particular useful for resolving dependencies on artifacts which are now provided through the JDK.

Question fifty four. What Is The Use Of Optional Dependency?

Answer :

Any transitive dependency may be marked as optionally available using "non-compulsory" detail. As instance, A depends upon B and B depends upon C. Now B marked C as non-obligatory. Then A will now not use C.

Question 55. What Is Dependency Exclusion ?

Answer :

Any transitive dependency can be exclude using "exclusion" detail. As example, A relies upon upon B and B depends upon C then A can mark C as excluded.

Question fifty six. How Can You Run The Clean Plugin Automatically During The Build?

Answer :

You can placed the easy plugin inside the execution tag in pom.Xml report

Question fifty seven. How To Stop The Propagation Of Plugins To Child Poms?

Answer :

set <inherited> to fake.

Question fifty eight. What Does The "you Cannot Have Two Plugin Executions With The Same (or Missing) Elements" Message Mean?

Answer :

It approach that you have completed a plugin a couple of instances with the same <id>. Provide every <execution> with a completely unique <id> then it'd be adequate.

Question 59. What Is A Mojo?

Answer :

A mojo is a Maven simple Old Java Object. Each mojo is an executable purpose in Maven, and a plugin is a distribution of one or more related mojos.

Question 60. What Is Difference Between Apache Ant And Maven?

Answer :

Ant is absolutely a toolbox while Maven is about the software of patterns so one can attain an infrastructure which presentations the traits of visibility, reusability, maintainability, and comprehensibility. It is incorrect to remember Maven as a build device and only a alternative for Ant.




CFG