简体   繁体   English

我可以在 EJB 3.1 项目中使用 Gin 和 Guice 吗?

[英]Can I use Gin and Guice in an EJB 3.1 project?

I'm going to start a Java EE project with EJB3.1 technology.我打算用 EJB3.1 技术开始一个 Java EE 项目。 I know the new EJB concept allows Context and Dependency Injection.我知道新的 EJB 概念允许上下文和依赖注入。

In an old project I used GIN and GUICE in a GWT Project.在一个旧项目中,我在 GWT 项目中使用了GINGUICE It was nice.很不错。 Can I use these frameworks also with EJB?我也可以将这些框架与 EJB 一起使用吗? Or do you think another framework would be a better choice?或者您认为另一个框架会是更好的选择?

Any Experience?任何经验?

It's possible as described in this tutorial: Guice Tutorial part 3 – Integrating Guice with EJB如本教程中所述,这是可能的: Guice 教程第 3 部分 – 将 Guice 与 EJB 集成

I'd choose Guice over any other DI framework我会选择 Guice 而不是任何其他 DI 框架

Or do you think another framewirk would be a better choice?还是您认为另一个 framewirk 会是更好的选择?

It's impossible to answer that without knowing any requirements.在不知道任何要求的情况下不可能回答这个问题。 CDI and EJB are defined in the same spec, so you can be absolutely certain that they play well together. CDI 和 EJB 在同一规范中定义,因此您可以绝对确定它们可以很好地协同工作。

It would also be important to know why you are planning to use EJB 3.1 (certainly not because the name sounds cool) and what features of EJB you want to use.了解您计划使用 EJB 3.1 的原因(当然不是因为这个名字听起来很酷)以及您想要使用 EJB 的哪些特性也很重要。

As a rule of thumb I would keep the core APIs together (EJB & CDI in this case), unless I had a very good reason to start mixing things.根据经验,我会将核心 API 放在一起(在本例中为 EJB 和 CDI),除非我有充分的理由开始混合使用。

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

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