javaspringspring-mvcjakarta-ee

How JavaEE and Spring are related / unrelated?


I am new to JavaEE and Spring Framework. I am having difficulty in understanding how we can write application using Spring Framework only. I have read over the internet that the intention of Spring Framework was to make development of enterprise level application simpler as opposed to EJB development (mainly in EJB 2.x series).

With JavaEE we have many technologies like: 1) EJB 2) JCP 3) JTA 4) JPA and so on.

While reading Spring Framework, i started with Dependency injection, Spring AOP, Spring MVC (and others i am reading).

I have difficulty in understand as to how just using Spring DI / AOP / MVC can it make full-blown Enterprise application? I read from one of the posts that, for example, for transaction management, we can use Spring's own Transaction management or use JTA. I believe JTA is part of JavaEE, and if we eventually use JavaEE's technologies, then how spring eases life?

Any answers which would help me clear this is highly appreciated.


Solution

  • Spring consists in many different parts, and so does Java EE. Some of them are direct competitors, while for others, Spring provides an abstraction layer and/or Spring integration of Java EE components.

    For example:

    So, for a typical webapp built with Spring, you will at least use some components of Java EE: servlets, maybe JDBC or JPA. If you need messaging and XA transactions, you'll use JMS and JTA, but Spring will provide an integration layer. Regarding dependency injection, you won't need EJBs and CDI, because Spring has direct support for the same functionality.