gpt4 book ai didi

java - CDI 可以减少到 Java SE 吗?

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:21:30 24 4
gpt4 key购买 nike

JSR-330 依赖注入(inject)可以应用于 Java SE 和 Java EE 环境,而 JSR-299 的标题是“Java EE 平台的上下文和依赖注入(inject)”。

除了严格面向 Java EE 的功能外,哪些 CDI 功能对 Java SE 也有意义?有可用的例子吗?谢谢!

[修订]这是 Weld on JSE.

最佳答案

Except strictly Java EE-oriented features, what CDI features make sense on Java SE as well? Any examples available? Thanks!

嗯,焊接文档中提到的那个:

18.4. Java SE

In addition to improved integration of the Enterprise Java stack, the "Contexts and Dependency Injection for the Java EE platform" specification also defines a state of the art typesafe, stateful dependency injection framework, which can prove useful in a wide range of application types. To help developers take advantage of this, Weld provides a simple means for being executed in the Java Standard Edition (SE) environment independently of any Java EE APIs.

When executing in the SE environment the following features of Weld are available:

  • Managed beans with @PostConstruct and @PreDestroy lifecycle callbacks
  • Dependency injection with qualifiers and alternatives
  • @Application, @Dependent and @Singleton scopes
  • Interceptors and decorators
  • Stereotypes
  • Events

这在 Java SE 上下文中显然是有意义的。

关于java - CDI 可以减少到 Java SE 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3575211/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com