如何处理一个API的两个版本 [英] How to deal with two versions of an API

查看:132
本文介绍了如何处理一个API的两个版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题:什么是处理两个不同版本的API的好办法? (子的问题:的有什么办法避免的classpath引用问题,如果你有使用相同的类名的两个库)

My Question: What is a good way to deal with two different versions of an API? (Sub-question: Is there any way to avoid classpath reference problems if you include two libraries with the same class-names?)

问题说明我有一个使用API​​的项目。我花了近几个月的旧版本开发和我即将添加功能的新版本。到目前为止,我可以告诉大家,只有一个关键的区别。不过,我没有API,但(在别人等着让我罐子里),所以我不能确定是否有更多的差异。

Description of question: I have a project that uses an API. I have spent the last few months developing for the old version and I'm about to add features for a newer version. So far as I can tell there's only one critical difference. However, I don't have the API yet (waiting on someone to get me the jar) so I can't be sure whether there are more differences.

subquestion的说明我担心可能有两种API之间的类引用不一致(就像我说的,我没有罐子虽然尚未肯定)。

Description of subquestion: I'm worried that there may be class reference inconsistencies between the two APIs (like I said, I don't have the jar yet to be sure).

我知道你可能需要一些code来看待,但是这是一个的设计的问题,而不是一个的编码问题。的,我希望能得到一些的最佳实践的出这一点。谢谢!

I realize you may want some code to look at, but this is a design question, not a coding issue. I'm hoping to get some best practices out of this. Thanks!

不重复的:我已经的看着在<一个href=\"http://stackoverflow.com/questions/225810/how-to-deal-with-multiple-versions-of-dependencies\">few可能出现的问题是重复的,但他们并没有真正解决我的问题:)

Not a duplicate: I've looked at a few questions which may appear to be duplicates, but they didn't really address my issue :)

推荐答案

避免或阴凉处。

如果您有您可以使用排序类路径的完全控制:这是脆,不直观

If you have full control of the classpath you can use ordering: this is brittle and non-intuitive.

如果你不这样做,你在任何的是,因此阴影,和其相关的头痛的摆布。

If you don't, you're at the mercy of whatever is, hence shading, and its related headaches.

这篇关于如何处理一个API的两个版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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