guice README

The project's README from github.com/google/guice. As one markdown file: README.md.

Guice

Overview

Put simply, Guice alleviates the need for factories and the use of new in your Java code. Think of Guice's @Inject as the new new. You will still need to write factories in some cases, but your code will not depend directly on them. Your code will be easier to change, unit test and reuse in other contexts.

Guice embraces Java's type safe nature. You might think of Guice as filling in missing features for core Java. Ideally, the language itself would provide most of the same features, but until such a language comes along, we have Guice.

Guice helps you design better APIs, and the Guice API itself sets a good example. Guice is not a kitchen sink. We justify each feature with at least three use cases. When in doubt, we leave it out. We build general functionality which enables you to extend Guice rather than adding every feature to the core framework.

Guice aims to make development and debugging easier and faster, not harder and slower. In that vein, Guice steers clear of surprises and magic. You should be able to understand code with or without tools, though tools can make things even easier. When errors do occur, Guice goes the extra mile to generate helpful messages.

For an introduction to Guice and a comparison to new and the factory pattern, see Bob Lee's video presentation. After that, check out our user's guide.

We've been running Guice in mission critical applications since 2006, and now you can, too. We hope you enjoy it as much as we do.

Installation Instructions

Guice Core (Maven)

<dependency>
  <groupId>com.google.inject</groupId>
  <artifactId>guice</artifactId>
  <!-- {version} can be 6.0.0, 7.0.0, etc. -->
  <version>{version}</version>
</dependency>

Guice Extension (Maven)

<dependency>
  <groupId>com.google.inject.extensions</groupId>
  <!-- {extension-name} can be one of: assistedinject, dagger-adapter,
       grapher, jmx, jndi, persist, spring, testlib or throwingproviders -->
  <artifactId>guice-{extension-name}</artifactId>
  <!-- {version} must match the guice core version. -->
  <version>{version}</version>
</dependency>

See Maven Central for more details, including snippets for other build systems such as Gradle, Ivy, sbt, and more.


jolt award

guice (google/guice)

Searching Database…

12.7K ·GitHub
这是什么?Guice 是一个轻量级的依赖注入框架,适用于 Java 11 及以上版本,由 Google 开发。它让你的代码不再需要工厂类,也不必手动调用 'new'。
它是框架还是库?它是一个库/框架,需要添加到 Java 项目的构建配置中。它提供 @Inject 等注解,以及你可以配置的模块,而不是一个独立的应用程序。
怎么把它添加到项目里?从 Maven Central 把 Guice Core 构件(以及你需要的任何扩展)添加到构建文件中。文档提供了 Maven、Gradle、Ivy、sbt 等多种配置示例。
我需要特定的 Java 版本吗?需要,Guice 要求 Java 11 或更高版本。
6.0.0 和 7.0.0 两个版本有什么区别?6.0.0 与 7.0.0 在功能上是等效的,区别仅在于支持的注入 API:6.0.0 主要支持旧的 javax.inject/servlet/persistence 命名空间,而 7.0.0 支持较新的 jakarta.inject/servlet/persistence 命名空间。
Guice 在生产环境中已经使用多久了?Google 表示,自 2006 年起就已在关键任务应用中运行 Guice。
Guice 是想做到面面俱到,还是保持精简?Guice 刻意保持精简:维护者要求任何新功能至少要有三个使用场景作为依据,并且倾向于构建通用的扩展点,而不是让核心变得臃肿。
除了 README,我还能去哪里学习如何使用 Guice?有用户指南,以及 6.0.0、7.0.0 和最新快照版本的 javadoc;还有 Bob Lee 的一段视频演示,介绍 Guice,并将其与直接使用 'new' 和工厂模式进行比较。
Creator
google
Size
122.4 MB
Stars
12.7K
Age
12y
Commits · 90 Days