Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How JavaEE and Spring are related / unrelated? [closed]

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.

like image 828
CuriousMind Avatar asked Dec 26 '22 03:12

CuriousMind


1 Answers

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:

  • Spring MVC is built on top of servlets (which are part of Java EE), and it competes with JAX-RS and JSF
  • Spring core (IoC, AOP) competes with CDI and EJBs
  • The Spring transaction handling is just an abstraction layer on top of existing transactional mechanisms (JPA, Hibernate, JDBC or JTA)
  • Spring-data-JPA is an abstraction layer on top of JPA
  • Spring-JDBC is an abstraction layer on top of JDBC

So, for a typical webapp built with Spring, you will at least use come components of Java EE: servlets, maybe JDBC or JPA. If you need messaging and XA, 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.

like image 146
JB Nizet Avatar answered Jan 09 '23 10:01

JB Nizet