Maven - difference between compile and provided scope

9 points
Created by:

In this short article, we will answer the question: what is the difference between compile and provided scope dependency during packaging JAR or WAR package.

Short answer:

compile scope will cause embedding dependency into the output JAR/WAR package, when

provided is used only during compilation, and later if the package will be required should be provided by an environment that uses package e.g. Tomcat server and his libraries, Lombok library when preprocessing is used, etc.

Maven documentation:

compileThis is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
providedThis is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. A dependency with this scope is added to the classpath used for compilation and test, but not the runtime classpath. It is not transitive.


  1. Dependency Scope - Maven Docs
Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

‚̧ԳŹūüíĽ ūüôā