gpt4 book ai didi

intellij-idea - Intellij 模块依赖项导出选项

转载 作者:行者123 更新时间:2023-12-04 11:40:27 24 4
gpt4 key购买 nike

在 Intellij 中,您可以在项目结构下添加模块依赖项。
依赖项选项卡下的导出下有一个复选框。如下所示。
enter image description here
我尝试选中 log4j 依赖项的复选框并重新编译它。输出路径中没有添加任何内容。如下所示。
enter image description here

谁能告诉我导出下的复选框有什么用?选中此复选框后的预期行为是什么?
评论:
在官方文件中,它说

The Export option lets you control the compilation classpath for the modules that depend on this one: the marked items will be included in the compilation classpath of the dependent module.


但我不明白这是什么意思。非常感谢。

最佳答案

有时,您需要敦促依赖模块中泄漏的依赖项。例如,您有模块 C,它是 B 的依赖项,如果 B 提供了一些您想要公开的 API 方法,例如,B 是库,您可能会使用模块 C 中的一些结构,并且当有人进入时没有检查“导出”例如,模块 A 将使用您的 API,访问这些结构存在问题,因为这些类不会被添加到模块 A 的编译类路径中。

A --- using this API requires C in compile classpath
|
B --- API uses these structures
C - data structures (should be exported when enumerated in B)
有时您不希望将依赖项泄漏到编译类路径中,因此您需要取消选中此选项
如果你不知道编译类路径是什么意思,请阅读: https://dzone.com/articles/runtime-classpath-vs-compile

关于intellij-idea - Intellij 模块依赖项导出选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62767891/

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