Maven Interview Questions
Maven Interview Questions
com/
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1) Explain what is Maven? How does it work?
Maven is a project management tool. It provides the developer a complete build lifecycle
framework. On executing Maven commands, it will look for POM file in Maven; it will run the
command on the resources described in the POM.
• Build
• Documentation
• Reporting
• Dependencies
• SCMs
• Releases
• Distribution
• Mailing list
In Maven, POM (Project Object Model) is the fundamental unit of work. It is an XML file which
holds the information about the project and configuration details used to build a project by
Maven.
Usually an artifact is a JAR file which gets arrayed to a Maven repository. One or more artifacts a
maven build produces such as compiled JAR and a sources JAR.
A Maven repository is a location where all the project jars, library jars, plugins or any other
particular project related artifacts are stored and can be easily used by Maven.
• Compile: It is the default scope, and it indicates what dependency is available in the
classpath of the project
• Provided: It indicates that the dependency is provided by JDK or web server or container at
runtime
• Runtime: This tells that the dependency is not needed for compilation but is required
during execution
• Test: It says dependency is available only for the test compilation and execution phases
• System: It indicates you have to provide the system path
• Import: This indicates that the identified or specified POM should be replaced with the
dependencies in that POM’s section
Profiles are specified in Maven by using a subset of the elements existing in the POM itself.
12) In Maven what are the two setting files called and what are their location?
In Maven, the setting files are called settings.xml, and the two setting files are located at • Maven
installation directory: $M2_Home/conf/settings.xml • User’s home directory: ${ user.home }/ .m2
/ settings.xml
• Validate
• Compile
• Test
• Package
• Install
• Deploy
14) List out the build, source and test source directory for POM in Maven?
• Build = Target
• Source = src/main/java
• Test = src/main/test
15) Where do you find the class files when you compile a Maven project?
jar: jar will not recompile sources; it will imply just create a JAR from the target/classes directory
considering that everything else has been done
https://www.guru99.com/
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
17) List out what are the Maven’s order of inheritance?
• Parent Pom
• Project Pom
• Settings
• CLI parameters
The minimum required elements for POM are project root, modelVersion, groupID, artifactID and
version.
19) Explain how you can produce execution debug output or error messages?
To produce execution debug output you could call Maven with X parameter or e parameter.
To run test classes in Maven, you need surefire plugin, check and configure your settings in
setting.xml and pom.xml for a property named “test.”
Project
Test Management Business Analyst Ethical Hacking PMP
Management
https://www.guru99.com/
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Software
Jenkins Agile Testing RPA JUnit
Engineering