导入包分辨率之间的区别:=可选,完全没有依赖性 [英] Difference between Import-Package resolution:=optional and no dependency at all
问题描述
我已阅读此处仔细使用导入包"指令中的可选分辨率,但并不真正理解为什么.另外,可选和根本不指定依赖项之间有什么区别?
I have read here to use the optional resolution within the "Import-Package" directive carefully, but don't really understand why. Also what is the difference between optional and not specifying a dependency at all?
推荐答案
如果根本无法指定Import-Package,则您的包将无法访问包,即使该包可用并由其他包导出了.
If you fail to specify an Import-Package at all, then your bundle cannot access the package even if it available and exported by some other bundle.
如果您有选择地导入软件包,则捆绑软件可以使用它(如果可用),但是该软件包不可用不会阻止捆绑软件的解决.
If you import the package optionally, then your bundle can use it if available, but that package not being available does not prevent resolution of your bundle.
您应避免在程序包级别使用可选的依赖项.您是否依赖于包装或不依赖于包装.通常,对可选依赖项的需求表明您的包具有较差的一致性,即,它在一个模块内执行了太多无关的事情.
You should avoid optional dependencies at the package level. Either you depend on a package or you don't. Normally a need for optional dependencies indicates that your bundle has poor coherency, i.e. it's doing too many unrelated things within one module.
这篇关于导入包分辨率之间的区别:=可选,完全没有依赖性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!