简体   繁体   English

等同于Spring Framework的Resource抽象

[英]An equivalent to Spring Framework's Resource abstraction

Spring Framework provides a wonderful abstraction layer for low-level resource access in Java (the Resource and ResourceLoader interfaces). Spring Framework为Java中的低级资源访问提供了一个很好的抽象层(Resource和ResourceLoader接口)。 I'm developing a library which should not be dependent on Spring, and am looking for an equivalent for this capability in a stand-alone Java library. 我正在开发一个不应该依赖于Spring的库,而是在独立的Java库中寻找这种功能的等价物。 Anyone familiar with one? 有人熟悉吗?

Why not just use the one from Spring by itself? 为什么不单独使用Spring中的那个呢? It doesn't look like it has any dependencies on the rest of Spring. 看起来它与Spring的其余部分没有任何依赖关系。

Edit 编辑

Not sure I understand the problem - you want something that does exactly the same thing, but doesn't come from Spring? 我不确定我是否理解这个问题 - 你想要的东西完全相同,但不是来自Spring? Is it a licensing issue? 这是许可问题吗?

You only need half a dozen classes from it, if you don't want to add them as an extra jar, move them to your own namespace (good idea anyway, in case you do use Spring at some point, after all) and distribute with your library. 你只需要它的六个类,如果你不想把它们作为一个额外的jar添加,把它们移动到你自己的命名空间(无论如何,好的想法,如果你在某些时候使用Spring,毕竟)并分发与你的图书馆。 Again, assuming your licensing allows it. 再次,假设您的许可允许它。

If licensing isn't the problem, can you be more specific about why you can't use the Spring implementation in your own library? 如果许可不是问题,您是否可以更具体地说明为什么不能在自己的库中使用Spring实现?

You can use Jsr-303 (DI) to match your requirments. 您可以使用Jsr-303(DI)来满足您的要求。 The most known implementation is Google Guice. 最着名的实现是Google Guice。 It's a javaEE standard (maybe JavaSE). 这是一个javaEE标准(也许是JavaSE)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM