在没有Servlet容器的情况下使用CDI [英] Using CDI without a Servlet Container
问题描述
我想使用Java Swing编写一个简单的Java桌面应用程序.通常,我使用 Spring Framework 进行依赖项注入并构建整个类结构.但是,我已经看到 CDI 越来越受欢迎,并且想尝试一下.
I want to write a simple Java Desktop Application using Java Swing. Usually I use Spring Framework to do the dependency injection and build the whole class structure. However, I've seen that CDI is becoming more and more popular and want to give it a try.
我想使用CDI对我的项目进行依赖注入,但是我不知道没有Servlet容器是否可以做到这一点(因为它使用的是Spring).每个教程似乎都与servlet容器或应用程序服务器有关.
I would like to do the Dependency Injection of my project using CDI, but I don't know if this is possible without a Servlet container (as it is using Spring). Every single tutorial seems to be related with servlet containers or application servers.
推荐答案
This is what you're looking for: https://openwebbeans.apache.org/owbsetup_se.html
CDI 2.0要求一个独立的容器,这太棒了!
CDI 2.0 mandates a standalone container, which is great!
这篇关于在没有Servlet容器的情况下使用CDI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!