本文介绍了CDI可以减少对Java SE的影响吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JSR-330依赖注入可以应用于Java SE和Java EE环境,而JSR-299则标题为Java EE平台的上下文和依赖注入。

JSR-330 dependency injection can be applied to both Java SE and Java EE environments, while JSR-299 is titled "Contexts and Dependency Injection for the Java EE platform".

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

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

[已修订]
这是

推荐答案

嗯,Weld文档中提到的那个:

Well, the one mentioned in the Weld documentation:

在SE环境中执行
时,Weld的以下功能是
可用:

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


  • 使用@PostConstruct和@PreDestroy生命周期回调的托管bean

  • 使用限定符和替代项的依赖注入

  • @Application,@ Dependent和@Singleton范围

  • 拦截器和装饰器

  • 刻板印象

  • 事件

  • 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环境中显然有意义。

This obviously makes sense in a Java SE context.

这篇关于CDI可以减少对Java SE的影响吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 19:40
查看更多