• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between maven "compile" and "provided" scope

 
Eric L Zhao
Greenhorn
Posts: 6
Java Linux Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am pretty new to maven and having a difficult time to understand the difference between maven's "compile" and "provided" scope. Could someone give a clear explanation?

Thanks,

Eric
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compile means that you need the JAR for compiling and running the app. For a web application, as an example, the JAR will be placed in the WEB-INF/lib directory.

Provided means that you need the JAR for compiling, but at run time there is already a JAR provided by the environment so you don't need it packaged with your app. For a web app, this means that the JAR file will not be placed into the WEB-INF/lib directory.

For a web app, if the app server already provides the JAR (or its functionality), then use "provided" otherwise use "compile".
 
Eric L Zhao
Greenhorn
Posts: 6
Java Linux Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Peter for such clear explanation!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic