The official documentation says
The most fundamental services provided by CDI are as follows:
but i still do not get the difference. Spring for example is DI and we still can access the context in it.
CDI gives you more opportunities. And provide it in some different way that Spring - is trying to rest more on the possibility of verification at compile time. But sometimes it is look like overhead. In a very small project EJB plus DI from JSF for example will be quite enough. But you can use CDI, only first it is worth reading more carefully about the main advantages in comparison with EJB's DI. There are many little details and you must think about where to use it.
I take it from " https://javatalks.ru/topics/40299 " and translate the closest answer for you. And I can advise to read this: " https://blogs.oracle.com/enterprisetechtips/using-cdi-and-dependency-injection-for-java-in-a-jsf-20-application " this is good article from Oracle engineer about using CDI and DI
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.