Prev Next

DevOps / Maven Interview questions II

1. Explain Build Profile in Maven. 2. What are different types of Build Profiles in Maven? 3. What are the build lifecycles of Maven? 4. Explain package phase in Maven build lifecycle. 5. What are the phases of 'site' lifecycle in Maven? 6. What is local repository in Maven? 7. What is Maven Central Repository? 8. Explain Maven remote repository. 9. How do I include dependencies in a jar using Maven? 10. Difference between Apache Ant and Maven. 11. Create an executable JAR with dependencies using Maven. 12. Configuring resource directories in Maven. 13. How do I enable connection to the central repository through the firewall in my organization? 14. Difference between repository and dependency in Maven. 15. What does the POM comprise of in Maven? 16. What is an Archetype in Maven framework? 17. What are the uses of Maven Plugins? 18. What are the types of Maven Plugins? 19. maven-surefire-plugin. 20. maven-surefire-plugin report directory. 21. List the report file formats. 22. What is goal in Maven? 23. Goals of Surefire Plugin. 24. How do you invoke the surefire Plugin? 25. Difference between Snapshot and Version in Maven. 26. What are the phases of 'clean' lifecycle in Maven? 27. Difference between install and deploy command in Maven. 28. Difference between package and install in Maven. 29. Difference between POM and Effective POM in Maven. 30. How do I exclude all the transitive dependencies of a single dependency in Maven? 31. Maven: How do I rename the war file for the project? 32. List out the aspects does Maven Manages? 33. Maven: how do you display execution debug output or error messages? 34. Difference between Maven and Jenkins/Teamcity/Hudson. 35. How do I prevent the propagation of plugins to child POMs? 36. How to find the POM that contains missing transitive dependency? 37. What does the Maven command mvn clean do? 38. How a new archetype based project be created from command line? 39. How do I compile the application sources using Maven from command line. 40. Can a Maven project have multiple parents? 41. Explain 'pom' packaging in Maven. 42. What is Maven relocation? 43. Can we change the .m2 folder to any other name like .p2 or something? How? 44. Difference between mvn install and package. 45. What is JAXB2 maven plugin and where will you use it? 46. What is Maven BOM? 47. What is the difference between -DskipTests and -Dmaven.test.skip=true?

1. Explain Build Profile in Maven.

A Build profile represents a set of configuration that is used to set or override default values of a Maven build. Using a build profile, a maven build can be customized for various application environments such as Production, Testing, Staging...

Read full answer

2. What are different types of Build Profiles in Maven?

There are 4 different types of build profile. Per Project.

Read full answer

3. What are the build lifecycles of Maven?

There are 3 built-in build lifecycles. The default lifecycle handles your project deployment....

Read full answer

4. Explain package phase in Maven build lifecycle.

package phase pulls the compiled code and package it to a distributable format, such as a JAR. The below is the command to package a maven project.

Read full answer

5. What are the phases of 'site' lifecycle in Maven?

The following are the phases of site lifecycle in Maven. pre-site, site, post-site, and site-deploy.

Read full answer

6. What is local repository in Maven?

Maven local repository is located in your local system and is created by the maven when you run any maven command. By default, maven local repository is %USER_HOME%/.m2 directory....

Read full answer

7. What is Maven Central Repository?

Maven central repository is located on the web created by the apache maven community. The path of central repository is: http://repo1.maven.org/maven2/.

Read full answer

8. Explain Maven remote repository.

Remote repositories refer to any other type of repository, accessed by a variety of protocols such as file:// and http://. These repositories are set up by a third party to provide their artifacts for downloading....

Read full answer

9. How do I include dependencies in a jar using Maven?

Using jar-with-dependencies as the descriptorRef of your assembly-plugin configuration, we can create a JAR along its dependencies. This built-in descriptor creates an assembly with the classifier jar-with-dependencies using the JAR archive format....

Read full answer

10. Difference between Apache Ant and Maven.

Ant and Maven are build tools provided by Apache Foundation. The purpose of these tools is to simplify the build process of a project....

Read full answer

11. Create an executable JAR with dependencies using Maven.

To build an executable jar using maven, we need to add manifest configuration to the maven-assembly-plugin. The below subset of pom.xml configure maven-assembly-plugin to create a single executable jar.

Read full answer

12. Configuring resource directories in Maven.

By default, Maven configures and lookup into the src/main/resources directory for your project resources. Also additional resources directories could be specified by adding the configuration to the project's Pom.xml.

Read full answer

13. How do I enable connection to the central repository through the firewall in my organization?

The HTTP proxy settings need to be specified in the file settings.xml. The encrypted passord could be specified in the file....

Read full answer

14. Difference between repository and dependency in Maven.

Repository is a collection of artifacts (eg: jars). You can think of it as a mere storage / cache of various artifacts....

Read full answer

15. What does the POM comprise of in Maven?

Maven POM contains the some of the following configuration. project version.

Read full answer

16. What is an Archetype in Maven framework?

Archetype is a Maven plugin that creates a project structure as per its template. The below is the command to create a new maven project based on an archetype.

Read full answer

17. What are the uses of Maven Plugins?

Maven plugin helps in, Creating jar and war. Compiling source code.

Read full answer

18. What are the types of Maven Plugins?

There are 2 types of maven plugins. Build plugins execute during the build and should be configured in the element of pom.xml....

Read full answer

19. maven-surefire-plugin.

The Surefire Plugin is applied during the test phase of the build lifecycle to execute the unit tests of an application. It also generates reports.

Read full answer

20. maven-surefire-plugin report directory.

By default, the reports are generated at ${basedir}/target/surefire-reports.

Read full answer

21. List the report file formats.

Plain text file (*.txt) XML file (*.xml)

Read full answer

22. What is goal in Maven?

A maven goal represents a specific task that contributes to the building and managing of a Maven project. It may be bound to zero or more build phases....

Read full answer

23. Goals of Surefire Plugin.

surefire:test, the only goal of the surefire plugin, runs the unit tests of an application.

Read full answer

24. How do you invoke the surefire Plugin?

By calling, mvn test

Read full answer

25. Difference between Snapshot and Version in Maven.

In terms of version, when maven has downloaded a dependency project version 1.0, it will not download again the latest version of 1.0 while building the project. To facilitate the latest version the dependent project need to do upgrades it's...

Read full answer

26. What are the phases of 'clean' lifecycle in Maven?

The clean lifecycle consists of the following phases. pre-clean, clean, and post-clean.

Read full answer

27. Difference between install and deploy command in Maven.

mvn:install copies your packaged Maven module to your local repository (by default, in ~/.m2/repository), to be accessed by other local Maven builds. mvn:deploy uploads your packaged Maven module to another (usually remote) repository, to be accessed by others.

Read full answer

28. Difference between package and install in Maven.

package : takes the compiled code and package it to its distributable format, such as a JAR. install : installs the package into the local repository, for use as a dependency in other projects locally.

Read full answer

29. Difference between POM and Effective POM in Maven.

All Maven POMs inherit defaults from the Super POM. For a basic Java project, we just need the Simplest POM, that defines a groupId, artifactId, and version, the three required coordinates for every project....

Read full answer

30. How do I exclude all the transitive dependencies of a single dependency in Maven?

In Maven2, exclude a every single transitive dependency using separate <exclusion> list which is complex. In Maven3 the use of wildcard is allowed on both groupId and artifactId that exclude all dependencies that propagates through to the module using this...

Read full answer

31. Maven: How do I rename the war file for the project?

use the finalName tag to define/change the name of the war file in the web module that produces the war. See the below example.

Read full answer

32. List out the aspects does Maven Manages?

Maven handles following aspects, Build. Documentation.

Read full answer

33. Maven: how do you display execution debug output or error messages?

To view/display execution debug output call Maven with X parameter or e parameter.

Read full answer

34. Difference between Maven and Jenkins/Teamcity/Hudson.

Maven is a build tool and also provides dependency management, standard project layout and project management. Jenkins/Teamcity/Hudson is a continuous integration tool which is much more than build tool....

Read full answer

35. How do I prevent the propagation of plugins to child POMs?

Setting inherited tag to false prevents the propagation to child POMs.

Read full answer

36. How to find the POM that contains missing transitive dependency?

Run "mvn -X" command.

Read full answer

37. What does the Maven command mvn clean do?

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

Read full answer

38. How a new archetype based project be created from command line?

A new project can be created using the command mvn archetype:generate .

Read full answer

39. How do I compile the application sources using Maven from command line.

Run the mvn compile command from the folder location where Pom.xml exists.

Read full answer

40. Can a Maven project have multiple parents?

Maven does not support multiple inheritance and a project can have only one parent. The parent project can have its own hierarchy.

Read full answer

41. Explain 'pom' packaging in Maven.

Pom packaging is used aggregate other projects and it acts as a container for sub modules within that project. Pom packaging is also used to identify the parent in non-modular context.

Read full answer

42. What is Maven relocation?

Maven relocation identifies the projects/artifacts that are relocated or moved on the repository. <project> <modelVersion> 4.0.0 </modelVersion> <groupId> bar </groupId> <artifactId> foo </artifactId> <version> 1.0 </version> <distributionManagement> <relocation> <groupId> org.bar </groupId> </re

Read full answer

43. Can we change the .m2 folder to any other name like .p2 or something? How?

Yes . The local repo folder name can be changed by updating in the settings.xml ....

Read full answer

44. Difference between mvn install and package.

mvn package takes the compiled code and package it in its distributable format, such as a JAR. mvn install installs the package into the local repository, for use as a dependency in other projects locally.

Read full answer

45. What is JAXB2 maven plugin and where will you use it?

JAXB2 maven plugin wraps and enhances the JAXB Schema Compiler (XJC) and allows compiling XML Schemas (as well as WSDL, DTDs, RELAX NG) into Java classes in Maven builds. This is plugin is used to generate web service clients from...

Read full answer

46. What is Maven BOM?

BOM (Bill Of Materials) is a special kind of POM used to control the versions of a project's dependencies and provide a central place to define and update those versions. BOM provides the flexibility to add a dependency to our...

Read full answer

47. What is the difference between -DskipTests and -Dmaven.test.skip=true?

-DskipTests compiles the tests, but skips running them. -Dmaven.test.skip=true skips compiling the tests and does not run them.

Read full answer

«
»

Comments & Discussions