Maven private dependencies(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 私有依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Maven 私有依赖


- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01