小足迹依赖注入java

发布于 2024-08-07 12:25:27 字数 144 浏览 4 评论 0原文

我正在寻找一个非常轻量级的java依赖注入框架。 具有尽可能少的依赖性和最少的功能。

只需遵循以下几行:接收 Classjava.util.List,实例化它们,然后将所有对象自动连接到另一个对象中。

I am looking for a very lightweight dependency injection framework for java.
With minimum possible dependencies and minimum features.

Just something along the following lines: receive a java.util.List of Classes, instantiate them and just auto-wire all the objects one into the other.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

凉栀 2024-08-14 12:25:27

我会推荐 Spring,因为当仅使用核心包时,它可以提供较小的占用空间。

如果您认为 Spring 太过分了,那么也许可以使用 PicoContainerguice

I would recommend Spring, since this can provide a small footprint when using only the core packages.

If you think Spring is overkill, then perhaps PicoContainer, or guice?

阪姬 2024-08-14 12:25:27

也许你应该看看 Google Guice:http://code.google.com/p/谷歌-guice/

Maybe you should have a look at Google Guice: http://code.google.com/p/google-guice/

未蓝澄海的烟 2024-08-14 12:25:27

Silk DI 是大约 120K 单个 jar 文件,没有进一步的运行时依赖项。它有一个像 guice 一样流畅的活页夹界面,但更灵活,并且允许删除您不喜欢的功能。例如,CollectionList 注入可以添加到一个衬垫中。

Silk DI is about 120K single jar file with no further runtime dependencies. It has a fluent binder interface like guice but is more flexible and allows to remove features you don't like. E.g. Collection or List injection can be added in a one liner.

遗失的美好 2024-08-14 12:25:27

我已经尝试 MentaContainer 不到一周了,我对其干净、简单的 API 感到满意。它没有使用 XML 或注释进行设置,而是使用流畅的 API,几乎像 DSL,这对我来说就像天堂一样,因为我使用它来构建一个支持 IoC 的小型 Web 容器。它为组件提供了一个 THREAD 范围,非常适合 Web 容器的 REQUEST 范围。它非常轻,所以它可能正是您所需要的。

I have been trying MentaContainer for less than a week now and I am satisfied by its clean and straightforward API. Instead of using XML or Annotations for the setup it uses a fluent API almost like a DSL which for me felt like like heaven because I am using it to build a small web container with IoC support. It provides a THREAD scope for the components which fits perfectly for the REQUEST scope of the web container. It is very lightweight so it may be what you need.

饮湿 2024-08-14 12:25:27

看一下 dagger2,它是由 google 开发的(由 square 的 dagger1 分叉),jar 大小只有 17kb。

  • 比 guice 编译时注入验证少得多的样板文件
  • (带有明确的错误消息。这是 spring 的东西,guice 绝对不会)
  • 在编译时生成 Facotries、代码。 非常强大

dagger2 文档
dagger2 github
dagger2 示例

Take a look at dagger2, developped at google (forked of square's dagger1), for only 17kb jar.

  • Much less boilerplate than guice
  • compile time verification of injection (with explicit error message. That's something spring, guice does definitly not)
  • generate Facotries, codes upon compile. Very powerfull

dagger2 documentation
dagger2 github
dagger2 examples

紫瑟鸿黎 2024-08-14 12:25:27

一定要调查吉斯。使用它已经一年了,非常喜欢它。

Definitely look into Guice. Been using it for a year, and absolutely love it.

深巷少女 2024-08-14 12:25:27

查看 ActiveJ Inject

它是一个轻量级的依赖注入库。它针对性能进行了优化,并且没有第三方依赖项。

它比 Spring DI 或 Guice 快得多,而且更轻。 此处查看基准测试

Take a look at ActiveJ Inject.

It is a lightweight dependency injection library. It is optimized for performance and has no third-party dependencies.

It is much faster than Spring DI or Guice and it is much lighter. Check the benchmarks here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文