Maven Interview Questions

19 May, 2020


Related Blogs


Maven Interview Questions and Answers

1. What is Maven?

Ans. Maven is a comprehension and software management tool, Maven can manage a building project, documentation and reporting based upon POM or the concept of the central piece of information in simple terms we can say Maven is a tool that can be utilised for managing and building Java-based projects.   

2. What are the ways that maven gives the developers to manage?

Ans. The ways that maven provides to the developers to manage are as follows 

  • Builds
  • Documentation
  • Dependents
  • Reporting
  • SCMs
  • Mail list
  • Distribution
  • Publication 

3. What are the goals of Maven?

Ans. Few considerable goals of maven are as given below

  • Maven provides a developer with the comprehensive model which is easy to use and also reusable
  • And also provides the tools that are interactive with the declarative models

4. What are the uses of Build Tools?

Ans. Below are the few of the uses of build tools 

  • Build Tool creates source code
  • Compiles the source code
  • Creates documentation from the source code

5. What are the characteristics of Maven?

Ans. Characteristics of maven are mentioned here

  • Very easy to use
  • Simple to understand
  • Fast to execute
  • Can work on multiple projects

6. What are the benefits of using Maven?

Ans. It helps in setting up the task rapidly and it keeps away from confounded form documents like build.xml. The pom.xml record is at the centre of Maven.POM.xml is an assortment of conditions of your Java Project which one can determine in Maven. 

It assists with packaging all the containers in your bundle for example in your War record or Ear document since every one of them will be put away in the vault. So next time any place you introduce this application that storehouse will be utilized for any conditions query. Thusly, your sending document will be exceptionally light

7. List the three build life cycles of Maven?

Ans. The three build life cycles of maven are

  • Clean this removes all the files which are generated by the earlier build 
  • Default this is responsible for the development of the project
  • Site by this we can create the documentation of project site  

8. Explain about archetypes?

Ans. The archetype means a Maven design templating toolkit. An archetype is described as a unique pattern or design of which entirely different things of a similar kind are presented.

9. Is it possible to create a custom archetype?

Ans. Yes, we can make a custom archetype. For instance, in our task, we made a custom archetype with modules as WEB, SERVICE and DAO. if we want to create the custom archetype manually we need to start with a newly created maven project and later we can attach the resources and we can create it by utilising the archetype-maven-plugin and later customize the data that is present in the archetype-resources directory and also archetype-metadata. XML file

10. Why do we use mvn-version?

Ans. Mvn-version command is used to know the version of maven that we are using to build our project 

11. Can you tell the location of the local repository?

Ans. ~ / M2 / repository is the command used to know the location of your local repository

12.” mvn package -Dmaven.test.skip=true” why do we use this command?

Ans. This command is used to skip test runs 

13. List the phases of the build life cycle of Mave?

Ans. The phases of the build life cycle of maven are as follows

  • Validate is used to validate the project is correct 
  • Compile in this phase the project code is compiled
  • Test the compiled code applying a suitable unit testing framework and those tests must not need the code packaged or deployed
  • Package this packs the compiled code into distributable formats like JAR
  • Integration test deploys and processes the package if needed within an n atmosphere where integration tests may run.
  • Verify it verify the package is still valid or not and also checks whether the package meets all the quality requirements or not 
  • Install this installs the package within the native repository   
  • Deploy copies the ultimate package into the remote repository as sharing among alternative developers and projects. This is arranged within a release environment or integration.

14. List the types of Maven repository?

Ans. There are three types of Maven repositories they are

  • Local repository is a folder place which is situated upon your own machine. this is generated while you run each maven command for the first point.  
  • Central repository this central repository contains an immense collection of frequently used libraries  
  • Remote repository when Maven is not capable to discover a specified dependency within the basic central repository then it holds that build process including an output error information is represented upon the console. To evade such a circumstance, Maven gives the concept of Remote Repository which is the developer owned design repository holding wanted other project jars or libraries.

15. List the different dependency scopes that are engaged in Maven?

Ans. Few dependency scopes that are engaged in maven are mentioned below

  • Compile this is a default scope and indicates the dependency which is given within the project’s classpath
  • Provided It symbolises that the dependency is given by an internet server or JDK or else container at runtime
  • Runtime This informs about the dependency is not needed for compilation, though, is required during the complete execution
  • Test It informs about the dependency is submitted simply to the proceeds a glance at execution and compilation phases
  • System path must be given by us
  • Import this implies that the observed or nominative pom to take displaced including all the dependencies inside the POM section 

16. Explain about “provided” which is a dependency scope in Maven?

Ans. It symbolises that this dependency is presented by JDK, internet server or else the container at the runtime.

17. Why do we use the mvn install command?

Ans. We can install the JAR file within the repository by using mvn install command

18. List the phases of the clean life cycle?

Ans. There are three phases of the clean life cycle they are

  • Pre-clean phase is utilised for many tasks that needed previous to the cleanup
  • Clean this phase is used to clean or delete  the files  
  • Post-clean this phase is utilised for the tasks by following the cleanup 

19. What is the default value for the project location of source code?

Ans. The default value for the project location of the source code is ${basedir}/src/main/java

20. What is the default value for resource files in maven?

Ans. The default value for the resource files in Maven is 


21. What is the default value for tests in maven?

Ans. The default value for tests in Maven is


22. What is the default value for compiled byte code?

Ans. The default value for compiled byte code in Maven is


23. What is the default value for distributable JAR?

Ans. The default value for distributable JAR in maven is


24. What is POM?

Ans. POM is abbreviated as the Project Object Model, POM is an XML file that dwells permanently as the project pom.xml in the base directory, this consists of other modules or packages like a WAR, JAR and EAR. if we execute any action on the outer container or package like MVN clean compile install. then the inner modules or packages also made a clean compile install. 

25. List a few configurations which are transitive in POM?

Ans. Few configurations that are transitive in POM are mentioned below

  • Project dependencies 
  • Goals
  • Plugins
  • Developers

26. List the minimal requirements for POM?

Ans. The minimal requirements of POM are

  • Project root
  • groupID
  • Model Version
  • Version
  • artifactID

27. What are the Maven plugins that are often used?

Ans. Few maven plugins that are often used are

  • Create a JAR file
  • Create WAR file
  • Compile the code files
  • Unit testing of the code
  • Documenting the projects
  • And finally reporting

28. How to specify the profiles within Maven?

Ans. We can specify the profiles by utilising the subset of elements that are already present within the POM

29. What is the use of the exclusion element?

Ans. We can exclude the dependency by using exclusion element

30. List the types of build profile?

Ans. There are three types of build profile they are

  • Pre-project
  • Pre-user
  • Global 

31. What is the command that we use to delete the target directory?

Ans. Mvn clean is the command used to delete the directory of data even before starting the process of the build

32. Explain about snapshot?

Ans. A special version which designates a modern development model. Unlike the usual versions, Maven analyses a brand-new SNAPSHOT version within its remote repository. Maven makes it as each build.

33. Explain about execution element?

Ans. Execution element consists of all the data that is required for executing the plugin

34. Write the syntax of a fully qualified artifact?

Ans. <groupId>:<artifactId>:<version> 

35. Explain about the deployment in maven?

Ans. Deploy is utilised to automatically establish the artifact, its pom and also the attached artifacts created through a specific project. maximum if not all of the data is associated with the deployment that is saved within the project of the pom.deploy-file is utilised to install an individual artifact simultaneously with the pom

36. How will you run the clean plugin during the build automatically?

Ans. We can run the clean plugin automatically just by inserting the clean plugin within the execution tag within the pom.xml file

37. How to exclude transitive dependency?

Ans. By using the “exclusion” element we can exclude the transitive dependency

38. Why do we use this command -mvn archetype: create?

Ans. By using this command we can create the new project upon a hard drive

39. Explain about prohibition?

Ans. Any kind of dependence can be prohibited utilising the ‘delete’ element. 

40.explain about the goal in the maven life cycle?

Ans. There are pre-phase and post-phase goals that run before and after the particular phase if once maven is ready to create a project then it follows the phases that are already defined and executed. The goal means a specific task which assists to manage and build a project.    


About Author


Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .