Você está na página 1de 6

10/6/2017 Interview Questions and Answers on Maven

Questions Tests IBM WCS Java Class List Best Of Java Discussion Forum Humor Classes Search Subscribe

WHICH IS THE BEST JAVA WEB FRAMEWORK ? SEARCH THIS BLOG

OpenXava Search

SPRING MVC Apache Stripes


Classes/Frameworks
Search

Code Snippets
Search
* Click to check More questions . There are more than 1600 questions currently in repository.
Interview Questions
Search
Interview Questions and Answers on Maven
Unix Command/Scripts
Search
Q1.What is Maven ?
DB Query/Scripts
Ans. Maven is a build automation tool used primarily for Java projects. Search

Q2.Difference between Maven and Ant ?

Ans. Ant is procedural, we need to provide information about what to do and when to do through code.

Maven is declarative, everything is de ned in the pom le.


Like Share 62 people like this. Be
the first of your friends.
Q3. What is the best practice configuration usage for files - pom.xml or settings.xml ?
Follow @buggy_bread
Ans. The best practice guideline between settings.xml and pom.xml is that configurations in settings.xml
must be specific to the current user and that pom.xml configurations are specific to the project.
Posts
Q4. How can I change the default location of the generated jar when I command "mvn
package"? Comments

Ans. By default, the location of the generated jar is in ${project.build.directory} or in your target directory.
TRANSLATE THIS PAGE Java
We can change this by configuring the outputDirectory of maven-jar-plugin.
Tweet Java SE
Select Language
Q5. What is Maven's order of inheritance?
Collect
Ans. Accurev Stream
annotations Reader
1. parent pom
apache active File
2. project pom
apache axis Except
3. settings
apache camel Iterato
4. CLI parameters
apache cassandra Lambd
apache commons Memo
Q6. What is a Mojo? apache ink Refere
apache hive String
Ans. A mojo is a Maven plain Old Java Object. Each mojo is an executable goal in Maven, and a plugin is a apache jena Thread
distribution of one or more related mojos. Zip
apache mahout
Apache OfBiz
Q7. How do I determine which POM contains missing transitive dependency?
apache pig New Cl

Ans. run "mvn -X" apache sling


apache spark 1.9
Q8. How would you see the version of Maven ? apache velocity 1.8
apache wicket 1.7
Ans. mvn --version apache xerces 1.6
bigdata 1.5
Q9. Where do we configure repositories in Maven ? 1.4
codeReview
collections 1.3
Ans. Within settings.xml in either MAVEN_HOME or .M2 directory.
crucible 1.2
dbunit 1.1
Q10. What are different type of repositories in Maven ?
designpattern 1.0
Ans. Local and Remote. Eclipse

http://www.buggybread.com/2014/05/interview-questions-and-answers-on-maven.html 1/6
10/6/2017 Interview Questions and Answers on Maven
ektorp
Q11. How does Maven looks for a dependency or resource ? enum
exceptions
Ans. It refers to the settings.xml to look for the repositories to look for the resource. First It looks into the explainCode
configured local repository, then it looks into the configured Remote repositories. If the resource is still not
sheye
found , it looks it within maven repository central i.e repo1.maven.org. If its still not found, it throws the
Frameworks
exception saying "Unable to nd resource in repository central".
freemarker
Q12. What is maven repository central ? grails
gwt
Ans. Its the repository provided by Maven. In case your POM specify the dependencies and its not available hadoop
in the configured local and the remote repository. It then looks for the resource in Maven Central. Maven heap
provides most of the generic dependency resources at this remote location. hibernate
hive
Q13. What would you do if you have to add a jar to the project using Maven ?
hypergraph
hypergraphdb
Ans. If its already there in Maven local repository, We can add that as a dependency in the project pom file
IBM WCS
with its Group Id, Artifact Id and version.
index
We can provide additional attribute SystemPath if its unable to locate the jar in the local repository. introduced
j2ee
If its not there in the local repository, we can install it first in the local repository and then can add it as Java
dependency. java 8
java 9
Q14. Have you ever had problem getting your projects in eclipse refreshed after you made
java frameworks
changes in the Pom files ?
java.applet
java.awt
Ans. Yes, It happens many times but I would usually perform mvn eclipse:eclipse and this would resolve
the project refresh problems. java.beans
java.io
Q15. What is the difference between compile and install ? java.lang
java.math
Ans. Compile compiles the source code of the project java.net
java.nio
whereas
java.rmi
java.security
Install installs the package into the local repository, for use as a dependency in other projects locally
java.sql

Q16. How can we see Dependencies for the project and where exactly they are defined ? java.util
java5
Ans. Using java6
java7
mvn dependency:tree java8
JavaScript
Q17. What is a transitive dependency ? Can we override Transitive Dependency version and If
javax.accessibility
Yes, how ?
javax.activation Java
javax.annotation
Tweet Ans. Transitive dependency is the dependencies not defined directly in the current POM but the POM of the Java SE
dependent projects. Transitive dependencies allows to avoid specifying the libraries that are required by javax.crypto
the project which are specified in other dependent projects - Remote or Local. javax.imageio
Collect
javax.lang
Stream
Yes we can override transitive dependency version by specifying the dependency in the current POM. javax.nio Reader
javax.security File
Q18. What is a cyclic dependency ? javax.sound Except
javax.sql Iterato
Ans. A has dependency of B, B has dependency of C and C has dependency of A.
javax.swing Lambd
With Maven 2 , came transitive dependency wherein in above scenario, C will acts as a dependency of A as jaxb Memo
if this dependency has been defined directly in A but the negative side is that if it leads to cyclic jdbc Refere
dependency , it creates problems. jersey
String
jira
Thread
Q11.What is the best practice con guration usage for les - pom.xml or settings.xml ? jquery
Zip
json
Ans. The best practice guideline between settings.xml and pom.xml is that con gurations in settings.xml must be speci c to jsp
the current user and that pom.xml con gurations are speci c to the project. New Cl
jstl
jung
Q12.How can I change the default location of the generated jar when I command "mvn package"? 1.9
junit
1.8
Ans. By default, the location of the generated jar is in ${project.build.directory} or in your target directory. We can change this jvm
1.7
by con guring the outputDirectory of maven-jar-plugin. lucene
1.6
maven
1.5
Q13.How do I determine which POM contains missing transitive dependency? mockito
1.4
mongodb
1.3
Ans. run mvn -X mvc
1.2
nosql
Q14.What would you do if you have to add a jar to the project using Maven 1.1
ocjp
1.0
oops
Ans. If its already there in Maven local repository, We can add that as a dependency in the project pom le with its Group Id,
oozie

http://www.buggybread.com/2014/05/interview-questions-and-answers-on-maven.html 2/6
10/6/2017 Interview Questions and Answers on Maven
Artifact Id and version. openxava
oracle adf
We can provide additional attribute SystemPath if its unable to locate the jar in the local repository.
orm
powermock
If its not there in the local repository, we can install it rst in the local repository and then can add it as dependency.
RAD

Q16.What is the difference between compile and install ? rcp


rest
Ans. Compile compiles the source code of the project search engine
servlet
whereas Shell Script
solr
Install installs the package into the local repository, for use as a dependency in other projects locally
Spring
spring framework
Q18.How can we see Dependencies for the project and where exactly they are de ned ?
spring mvc

Ans. Using spring projects


spring security
mvn dependency:tree springframework
sql
Q19.What are the bene ts of transitive depency in Maven ? string
Struts
Ans. Transitive dependencies allows to avoid specifying the libraries that are required by the project which are speci ed in
svn
other dependent projects - Remote or Local.
swt
threads
Q20.What is the difference between Maven, Ant and Jenkins ?
ubuntu
Ans. Maven and Ant are Build Technologies whereas Jenkins is a continuous integration tool. Unix
Unix Application Support
Q21.Have you heard of Ban Duplicate Classes Maven enforcer plugin ? What is its use ? vraptor
WCSDB
Ans. Yes , we have been using this plugin with our projects and its purpose is to warn and stop the Build if there are duplicates WCSSQLCon g
of the same package and class are being carried either directly or through transitive dependencies. the duplicate could be
weblogic
coming through different types of dependencies or through different versions of the same dependency. Its purpose is to make
xml
sure that there is only one copy thats being used at compile time and runtime and hence shouldnt later result in runtime
problems.
POPULAR POSTS
Q22.How to tackle duplicate classes in maven build ?
Online Test - Unix
Commands 1
Ans. The simplest way is to ignore them if Maven enforcer plugin is complaining about it but it may lead to runtime problems
later. Index

We can do the dependency:tree to see from where these duplicate ones are coming and hence can exclude the duplicate one. Online Practice Test -
Java - OOPS and
Collections
Q23.What are different dependency scopes in Maven ?
Online Practice Test -
Ans. Compile Java - OOPs 2 Java
Tweet Java SE
This is the default scope. Compile dependencies are available in all classpaths of a project. Moreover, these dependencies are Online Practice Test -
Spring Framework 1
propagated to dependent projects. Collect
Java / J2EE Technical Stream
Provided Architect - Interview
Reader
Questions and Answers
File
This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime.
500 Java / J2EE Interview Except
Questions and Answers
Runtime Iterato
Online Practice Test - Lambd
This scope indicates that the dependency is not required for compilation, but is for execution. Java - Threads Memo
Refere
Online Practice Test -
Test BigData Hadoop String
Thread
This scope indicates that the dependency is is only available for the test compilation and execution phases. This scope is not Online Test - Java - OOPS
Zip
transitive. - Abstract Classes and
Interfaces
New Cl
System

This scope is similar to provided except that you have to provide the JAR which contains it explicitly. #WCS Consultant 1.9
Openings - Anywhere in
USA-9/29/2015-Harish 1.8
Q24.How do you resolve Maven Dependencies issue while upgrading dependencies versions ? Re: 1.7
WCS-12/17/2014-Faha 1.6
Ans. Step 1 - Upgrade the required dependency , perform build and check build errors d
1.5
Re: IBM WebSphere
1.4
Step 2.1 - If the error is of missing transitive dependency ( which is rare and means that the previous version has a dependency Commerce
8-12/16/2014-buggybr 1.3
which is missing in the later version ), I would look for the dependency in google and hence will include it as direct dependency ead
1.2
in Pom le.
Re: WCS7 Study
1.1
Material-12/16/2014-b
Step 2.2. If the error is for Duplicate dependencies , and the choice is between transitive and direct dependency, I usually uggybread 1.0
remove the direct dependency.

http://www.buggybread.com/2014/05/interview-questions-and-answers-on-maven.html 3/6
10/6/2017 Interview Questions and Answers on Maven
Re: IBM WebSphere
Step 2.3 - If the error is for Duplicate dependencies , and both are transitive dependencies. I rst make a choice ( usually later Commerce
8-12/16/2014-Rakesh
version ) and then ignore the previous version dependency.

Step 2.4 - If the error is for Duplicate dependencies , and there are more than 2 duplicates, I usually ignore it by specifying TOTAL SITE VIEWS
within maven-enforcer-plugin con g.

Step 3 - Perform a Clean Build.


3,117,150
Step 4 - Check Maven Dependency Tree to make sure that Duplicates have been removed or dependency is there in case of
missing dependency.
CONTACT US - SEND US
TECHNICAL QUERIES - WE
Step 5 - Perform tests and make sure that there are no runtime problems. WILL BE HAPPY TO HELP.

Name
Step 6 - If there are runtime problems ( which very likely occurs if you have different version dependencies , very likely by
doing 2.4 , you will have to remove step 2.4 and alternately perform 2.2 or 2.3 )
Email *
Q25.What is a Test Dependency Scope in Maven ?

Ans. This scope indicates that the dependency is not required for normal use of the application, and is only available for the
Message *
test compilation and execution phases. This scope is not transitive.

Q26.What is the POM packaging in Maven ?

Ans. pom packaging is simply a speci cation that states the primary artifact is not a war or jar, but the pom.xml itself.

Q27.Difference between Maven Project and Module ? Send

Ans. Maven Module has a Parent whereas Project doesnt. when we add the parent section to the pom le, it adds the module
section to the parent project pom le. When we execute mvn compile / install, it basically checks that module section of the
parent to identify all the modules that needs to be compiled rst.

Q28.How to specify the sequence in which sub modules needs to be built ?

Ans. By specifying the modules in the same sequence in the parent pom.

Multiple Choice Questions

Q29. What is Maven's order of inheritance?

a. parent pom -> project pom -> settings -> CLI parameters
b. project pom -> parent pom -> settings -> CLI parameters
c. settings -> parent pom -> project pom -> CLI parameters
d. CLI parameters -> settings -> parent pom -> project pom
Java
Tweet Ans. parent pom -> project pom -> settings -> CLI parameters Java SE

Q30. How do I determine which POM contains missing transitive dependency? Collect
Stream
a. mvn -A
Reader
b. mvn -M
File
c. mvn -R
Except
d. mvn -X
Iterato
Ans. mvn -X Lambd
Memo
Q31. What is the sequence in which Maven looks for the resources ? Refere
String
a. Remote-> Maven Central - > Local Thread
b. Local -> Remote - Maven Central
Zip
c. Remote-> Local -> Maven Central
d. Maven Central -> Local -> Remote
New Cl

Ans. Local -> Remote - Maven Central


1.9
Q32. POM stands for ... 1.8
1.7
a. Project Object Model 1.6
b. Project Oriented Model 1.5
c. Prospective Object Model
1.4
d. Prospective Objective Model
1.3
1.2
Ans. Project Object Model
1.1
Q33. Which of the following is not type of Maven Repository ? 1.0

http://www.buggybread.com/2014/05/interview-questions-and-answers-on-maven.html 4/6
10/6/2017 Interview Questions and Answers on Maven
a. Local
b. Remote
c. Maven Central
d. Maven Local

Ans. Maven Local

Q34. What is the default location of local repository ?

a. ~/.m2/repo
b. ~/m2./home/repository
c. ~/m2./repository
d. ~/m2./home/repo

Ans. ~/m2./repository

Q35. Which of the following is not type of Maven Plugin ?

a. Build
b. Reporting
c. Remote
d. All are valid Maven Plugin types

Ans. Remote

Q36. Which of the following is not a dependency scope in Maven ?

a. Compile
b. Test
c. System
d. Export

Ans. Export

Q37. What is a project's fully qualified artifact name?

a. <groupId>:<artifactId>:<version>
b. <groupId>:<artifactId>
c. <artifactId>:<groupId>:<version>
d. <artifactId>:<version>

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

Q38. Which of the following is dependency exclusion ?

a. A doesn't depend on C and then A marks C as excluded.


b. A Depends on B and B depends on C and then A can mark B as excluded. Java
Tweet c. A and B depends on C and then they can mark C as excluded. Java SE
d. A depends upon B and B depends upon C then A marks C as excluded.
Collect
Ans. A depends upon B and B depends upon C then A marks C as excluded. Stream
Reader
File
Except
You might also like:
Iterato
Maven - Interview Questions and Answers on Dependencies
Lambd
ERROR - Maven - The goal you speci ed requires a project to execute but there is no POM in this directory
Java - Interview Questions and Answers on Build and Compilation Memo
Build Manager / Build and Release Manager - Interview Questions and Answers Refere
ERROR - Invalid packaging for parent POM /xyz/pom.xml), must be "pom" but is "jar"
String
Linkwithin
Thread
Zip
Like 16 Tweet Share 4

Like 16
New Cl

1.9
1.8
1.7
Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
7 Enter your email address: Subscribe
1.6
1.5
Delivered by FeedBurner
Share 1.4
1.3
1.2
1.1
1.0

http://www.buggybread.com/2014/05/interview-questions-and-answers-on-maven.html 5/6
10/6/2017 Interview Questions and Answers on Maven

0 Comments Buggybread
1 Login

Sort by Best
Recommend Share

Start the discussion

LOG IN WITH
OR SIGN UP WITH DISQUS ?

Name

Be the first to comment.

ALSO ON BUGGYBREAD

Difference between == and .equals() ? Java 8 - Interview Questions and Answers on


2 comments a year ago Effectively Final
vivekvermani It will never make sense to have 1 comment 3 years ago
both in single If statement as == means that they infoj When a lambda expression uses an
point to the same memory location and hence assigned local variable from its enclosing space
there is an important restriction. A lambda

Java - Collections - Interview Questions and Java - Advanced Interview Questions for
Answers on TreeSet Experienced Professionals
2 comments 3 years ago 2 comments 3 years ago
vivekvermani Hi Vinoth. Seems like the correct Rajashekar J Its amazing explanation in
question has not been referenced as I am not simple way. Thank you guys
able to understand your comment. Regards.

Subscribe d Add Disqus to your siteAdd DisqusAdd Privacy

Contact us at info@buggybread.com
Java
Tweet buggybread.com Java SE

Powered by Blogger. Collect


Stream
Reader
Disclaimer: The intent of the site is to help students and professional in their academics and career.Though best effort are made to present the most accurate information, No File
guarantees are made regarding the accuracy or usefulness of content.The site holds no responsibility of any harm to anyone because of provided information. Except
Iterato
This site contains some content ( interview questions ) submitted by users. If you have any concern regarding the copyright of the content, Contact us with the original reference
and the content will be removed. Lambd
Memo
Refere
String
Thread
Zip

New Cl

1.9
1.8
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1.0

http://www.buggybread.com/2014/05/interview-questions-and-answers-on-maven.html 6/6

Você também pode gostar