gpt4 book ai didi

maven - maven范围编译和为JAR打包提供的区别

转载 作者:行者123 更新时间:2023-12-03 04:05:48 25 4
gpt4 key购买 nike

当 Artifact 构建为 JAR 时,maven 范围 compileprovided 之间有什么区别?如果是 WAR,我会理解 - 该 Artifact 将包含或不包含在 WEB-INF/lib 中。但对于 JAR 来说这并不重要——不包含依赖项。当它们的范围是compileprovided时,它们必须位于类路径上。我知道 provided 依赖项不可传递 - 但这只是一个区别吗?

最佳答案

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

Here is the reference.

关于maven - maven范围编译和为JAR打包提供的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6646959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com