39

Now I am reading "Begining Java EE 7". And I was wondered that Java EE 7 is a good stack of technologies, it includes CDI, bean validation, JSF for web tier and other specifications.

So I got a question:
Why should I study Spring framework if Java EE 7 exists and covers all capabilities which Spring implements?

informatik01
  • 16,038
  • 10
  • 74
  • 104
Korobko Alex
  • 816
  • 1
  • 7
  • 10

2 Answers2

31

I will share little bit of what I know about using Spring. You are right by saying that Java EE 7 has all the technologies to help solve the problems.

Well Spring just enhances these capabilities and makes life more easier for a developer.

As an example when you use Spring MVC framework you can use Spring UI tags to create your JSP and those tags in turn can help you map the values directly to your controller. By controller I mean the Java class which is invoked when you do form submit. It also helps you to validate the form data.

This can be achieved using the Servlet technology also but Spring lets you focus on business logic and it takes care of these.

In my experience as a developer its good to know and understand Java EE 7 but frameworks like Spring utilize some of the best practices and patterns to make life easier for developers.

Would like to hear the opinions from others as well.

Hope this helps.

Ankur
  • 467
  • 4
  • 7
  • 12
    Generally I don't think plain JSP should be anymore used for rendering the UI. If you use JSF the same will be achieved as you described Spring does for value mapping with backing objects. E.g. When you use bean validation the JSF will automatically inform you about validation errors (Tested with PrimeFaces. No need to handle any params with controllers unless explicitly wanted). You can also map entities (JPA) directly to UI with JSF. It seems JavaEE7 may be a bit more complicated than Spring to start with, but for me it seems it is more robust and may be a bit more handy at the end. – Ville Myrskyneva Feb 17 '14 at 07:58
  • 2
    I think anyone espousing the virtues of a framework that *helps* you write in decade old 'action oriented' frameworks like JSP really needs to re-analyse their technology stack. 'Component oriented' frameworks like Wicket, JSF, Tapestry are really very mature and increase your productivity in an amazing way. I can't speak for the others but Wicket handles all of the Web 2/AJAX stuff in a transparent way (if you want it to) but still allows you to hack away in JS if you're that way inclined. I find I rarely need to revert to JS - or as I like to call it "web assembler language" – Volksman Jan 13 '15 at 21:52
  • 1
    I agree, his example is bad. When I read JSP I shuddered. But I use Spring and have for a long time. No reason at all to be using JSP. You CAN if you want, but you shouldn't. There are many tie ins to various front end frameworks like JSF, Velocity, Thymeleaf, Freemarker, Wicket, etc. They don't force you down any path. – Kevin M Mar 26 '15 at 14:54
  • 1
    People, always evaluate who is giving you the advice. Spring has no view framework. Nowadays, Thymeleaf is commonly used. But this only reinvents JSF and Thymeleaf can be used with JEE too, it is even easier. JEE has JSF, but has even better MVC than Spring too. Even for REST, JAX-RS is better and cleaner, easier to document too. But JEE has extensions and goes even further: http://ocelotds.org/, https://bessemhmidi.github.io/AngularBeans/ . This answer is misleading and results from poor knowledge. –  Nov 01 '16 at 12:28
19

I think that one simply should know both of them. Spring has a huge community and is used widely, but Java EE is now going forward too, using many technologies that are in Spring in its latest versions.

However, it is incorrect to say that Java EE covers all the fields that Spring does. In my opinion Spring still has something that could make the difference, if you work in particular domains, such as mobile (Spring mobile), social (Spring social), navigation flows management (Spring Webflow) and others.

umanganiello
  • 756
  • 4
  • 7
  • 1
    Again, not true. JEE has many things that are not present in Spring and doesn't seem to be in near future. Proper event mechanisms, view frameworks (Spring has none up-to-date view technology to integrate with, maybe Thymeleaf). Spring Social can be easily beaten by Agorava: http://www.agorava.org/. The same goes for security and other projects. Please note that JEE has extension mechanism and developers are no longer required to contribute to a project controlled by one company. Even Spring Data is now available as a CDI plugin, but we have much better project called Apache Deltaspike. –  Nov 01 '16 at 12:32