Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scope "provided" does not add in jars in classpath

I am using a dependency of scope "provided" pom file of an artifact. Because of "provided" scope, those dependency jars are not added in classpath of MANIFEST.MF.

Could you help me so that the jars should not be downloaded but should be added in classpath.

like image 644
sridhar Avatar asked Jun 20 '12 06:06

sridhar


People also ask

What does provided scope mean in Maven?

Maven dependency scope – provided Maven dependency scope provided is used during build and test the project. They are also required to run, but should not exported, because the dependency will be provided by the runtime, for instance, by servlet container or application server.

What are scope dependencies are not available in Maven?

Maven includes a dependency with this scope in the runtime and test classpaths, but not the compile classpath. This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases. This scope is not transitive.

What is the difference between compile and provided scope in Maven?

compile This 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. provided This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime.


1 Answers

Well, if you want it semantically right, remove <scope>provided</scope> and leave it default (<scope>compile</scope>). Then set <optional>true</optional> for a dependency, so it will be included in manifest's classpath.

By using provided scope you actually say that you don't want it to be in manifest's classpath since it's anyway provided by the container.

like image 177
Michał Kalinowski Avatar answered Oct 21 '22 10:10

Michał Kalinowski