有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (1) 个答案

  1. # 1 楼答案

    将“提供的”依赖项更改为“编译”依赖项。由于它是默认范围,请删除依赖项中的范围标记

    引用the documentation,我的重点是:

    • 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. 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.

    简而言之:标记为“已提供”的依赖项不包括在您的构建中,因为通过将其声明为已提供,您告诉Maven,它不必将其包括在您的构建中,因为其他东西