Multiple Dependency Scopes in POM

后端 未结 6 1786
离开以前
离开以前 2021-02-05 01:02

I have a dependency in my POM that needs to be set to \"provided\" so it is not included at compilation, but it can still be referenced within my project. I would like the same

6条回答
  •  名媛妹妹
    2021-02-05 01:45

    From maven documentation:

    provided This 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. This scope is only available on the compilation and test classpath, and is not transitive.

    I checked this works for me in maven 3.0.3. Had the same issue that i needed to have a servlet dependency while compilation and test but not compiled in because it ships with the application server distribution.

提交回复
热议问题