Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

Maven Interview Questions and Answers For Freshers Part-4

Be First!

maven31.When does Maven use External Dependency concept?
Maven dependency management using concept of Maven Repositories (Local, Central, Remote). Suppose dependency is not available in any of remote repositories and central repository; in such scenarios Maven uses concept of External Dependency.

32.What are the things you need to define for each external dependency?
External dependencies (library jar location) can be configured in pom.xml in same way as other dependencies.

Specify groupId same as name of the library.

Specify artifactId same as name of the library.

Specify scope as system.

Specify system path relative to project location.

33.What is Archetype?
Archetype is a Maven plugin whose task is to create a project structure as per its template.

34.What is the command to create a new project based on an archtype?
Type the following command −

mvn archetype:generate

35.What is SNAPSHOT in Maven?
SNAPSHOT is a special version that indicates a current development copy. Unlike regular versions, Maven checks for a new SNAPSHOT version in a remote repository for every build.

36.What is difference between Snapshot and Version?
In case of Version, if Maven once downloaded the mentioned version say data-service:1.0, it will never try to download a newer 1.0 available in repository. To download the updated code, data-service version is be upgraded to 1.1.

In case of SNAPSHOT, Maven will automatically fetch the latest SNAPSHOT (data-service:1.0-SNAPSHOT) everytime app-ui team build their project.

37.What is transitive dependency in Maven?
Transitive dependency means to avoid needing to discover and specify the libraries that your own dependencies require, and including them automatically.

38.What does dependency management mean in the context of transitive dependency?
It means to directly specify the versions of artifacts to be used when they are encountered in transitive dependencies. For an example project C can include B as a dependency in its dependencyManagement section and directly control which version of B is to be used when it is ever referenced.

39.How Maven handles and determines what version of dependency will be used when multiple version of an artifact are encountered?
Maven determines what version of a dependency is to be used when multiple versions of an artifact are encountered. If two dependency versions are at the same depth in the dependency tree, the first declared dependency will be used. This is called dependency mediation.

40.What is dependency scope? Name all the dependency scope.
Dependency scope includes dependencies as per the current stage of the build. Various Dependency Scopes are −

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

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

runtime − This scope indicates that dependency is not required for compilation, but is required during execution.

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

system − This scope indicates that you have to provide the system path.

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

(174)

Previous
Next

Leave a Reply