Maven 私有依赖 [英] Maven private dependencies

查看:32
本文介绍了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 私有依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆