Maven 私有依赖

Maven private dependencies(Maven 私有依赖)
本文介绍了Maven 私有依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法为其他人不可见的项目指定私有依赖项?

Is there a way to specify private dependency for a project that will not be visible to others?

我想要达到的效果与排除功能非常相似,但略有不同 - 用户根本不应该意识到这种依赖关系,因此不必明确使用此排除.

What I'm trying to achieve is pretty much similar to what exclusion does, but with one slight difference - user should not be aware of that dependency at all and, thus, won't have to use this exclusion explicitly.

如果这是不可能的(这很可能是真的),那么有什么特别的原因吗?

And if this is not possible (which, most likely, is true), then is there any particular reason why?

推荐答案

可选的依赖听起来像你想要的.将依赖项标记为 optional 并且您将在构建时拥有它,但用户不会自动将该库包含为传递依赖项.

Optional dependencies sound like what you want. Mark a dependency as optional and you'll have it when you build, but users won't automatically have that library included as a transitive dependency.

参见 Maven - 可选依赖和依赖排除 了解更多详情.

See Maven - Optional Dependencies and Dependency Exclusions for more details.

'provided' 在这里并不是理想的解决方案;这意味着需要一个依赖项,但是它将由您的工件的任何用户提供.'optional' 表示依赖项仅对某些功能是必需的.

'provided' is not the ideal solution here; that means that a dependency is required, but that it will be provided by any user of your artifact. 'optional' means that the dependency is only required for some functionality.

这篇关于Maven 私有依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

JPMS/Jigsaw Missing Main Class in Module(JPMS/Jigsaw模块中缺少主类)
Can not run JAVAFX .jar File (many errors occurred)(无法运行JavaFX.jar文件(出现许多错误))
JPMS and fatuber executable JAR - how it works together?(JPMS和FATUBER可执行JAR--它是如何协同工作的?)
Use jdk.internal.net.http(使用jdk.inder.net.http)
javax.annotation classes and Java 11 JDK(Javax.Annotation类和Java 11 JDK)
Are Filer#39;s originating elements useful?(FILLER的原始元素有用吗?)