Whats the difference between Spring and Spring MVC? - spring

I know this is not a programmatic questions.
I am a n00b to this area coming from Java EE background and could not find the difference between the two online (may be I am not a good surfer)
Could someone please share the info?

Spring is a framework alternative to Java EE with three parts:
Dependency injection
Aspect oriented programming.
Libraries for web MVC, persistence, messaging, etc.
Spring MVC is for web MVC. It's one of the many libraries built into Spring. You can use other alternatives (e.g. Struts, SEAM, etc.) if you wish and still use Spring.

spring is enterprise framework designed to solve all your problems for enterprise applications. At present they call it as Spring IO, which can be found at spring.io website.
However, Spring MVC is a framework part of the whole stack available to solve the enterprise solutions. This is framework for writing web applications.

Related

Spring MVC vs Java EE

So I'm about to learn Spring MVC. But what I don't understand is why should I use Spring MVC if I can implement the MVC pattern using a single servlet conroller and JSPs? What advantages does Spring MVC provide over simple java MVC pattern?
Actually yes, you can do it. Question is if you should do it. Spring MVC gives you better organization of your code.
Pure MVC Frameworks like Spring MVC are obsolete today. When combined with templating engines like Thymeleaf, it lacks functionality and developers usually reinvent JSF. For single-page apps based on some popular JS frameworks that need REST backend, JAX-RS is way cleaner and better than Spring MVC REST.
So no, today you don't need Spring MVC and can stick with pure Java EE. For simple, toy-like applications where servlets are enough, you don't really need it but it may be better to use it. For anything serious, MVC is outdated and Spring has nothing to offer.
Edit 2017: Spring offers JAX-RS integration. However, it has several pitfalls, for example Spring won't automatically register classes annotated with #Path for you. Details can be found in Dzone Article
The best way to realize that it's better to play with these technologies for yourself, if you want to try spring MVC I recommend you start with spring boot because you can create projects with more agility without configuring xml files
Spring Boot
Some Features
Create stand-alone Spring applications
Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
Provide opinionated 'starter' POMs to simplify your Maven configuration
Automatically configure Spring whenever possible
Provide production-ready features such as metrics, health checks and
externalized configuration
Absolutely no code generation and no requirement for XML configuration
One of the ideas applied in Spring (not invented by Spring) is
Do not reinvent a wheel.
Having a single controller is not a good idea I'd say - breaking separation of concerns principle.
You can learn more about MVC from Spring documentation.

Starting with Spring framework

I'm planning to start learning Spring but when I open any spring tutorial, I find many modules like Spring REST, spring MVC etc.
I'm really confused on how to start with spring, from which module to start, how are these modules related to each other, should I go through all the modules??
I tried searching many sites to answer my questions but couldn't find satisfactory ans, so thought of posting here. It would be great if somebody can guide me in this regard.
Spring is a java framework which provides solutions to several problems. So i guess it really depends on what you are planning to learn. The most important to learn first is understanding what Dependency Injection and inversion of control means. When you understand this you will understand why the rest of the frameworks are designed as it is. i suppose learn Spring IoC first since this is basically the core component of Spring Framework. Link: http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/beans.html
After learning Spring IoC, you can go on learning each specific Spring frameworks which address specific problems. For example:
Are you interested in Web development? --> Spring MVC
Are you interested in storing data to database? --> Spring Data
Are you interested in developing web services / web apis --> Spring REST
http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/overview.html
Start with Spring Core Module, which is the heart of entire Spring.
Spring Core Module helps in Injecting Dependencies (java objects) into
the Application at Runtime.
Please refer below URL for more details:
http://www.springbyexample.org/examples/core-concepts.html
A good knowledge of design patterns is essential for learning any framework in Java.
These Youtube videos can give you a good understanding of basic Spring.
As explained in the previous answers, start learning with the Spring core. You need to have a sound knowledge of servlets, JSP, Hibernate (ORM's) to understand the advanced topics.

what is difference between spring framework and spring roo

Can anyone clarify what are the differences between Spring Framework, Spring ROO, and Spring MVC ? I am really puzzled by these similar terms and cannot mangage find an answer.
It's really easy:
Spring Roo is a DEVELOPMENT-TIME tool, similar to Eclipse, IntelliJ, etc.
Spring Framework is a RUN-TIME framework.
Applications generated with Spring Roo at development time use Spring Framework at run time.
Hope this helps.
I do not want to be rude, but also from SO tags we know:
spring
The Spring Framework is an open source framework for application development on the Java platform. At its core is rich support for component based architectures, and it currently has over a dozen highly integrated modules.
https://stackoverflow.com/tags/spring/info
spring-mvc
Based on the Model-View-Controller (MVC) pattern, Spring MVC helps you build web-based applications that are flexible and decoupled from the underlying view technologies.
https://stackoverflow.com/tags/spring-mvc/info
spring-roo
Spring Roo is a lightweight tool aimed at developer productivity. Via an intuitive command line interface it supports operations such as Java web project creation, persistence configuration and view scaffolding. Roo creates a Java web project that uses the Spring framework, and leverage some best ...
https://stackoverflow.com/tags/spring-roo/info
My own brief description would be: Spring framework is the framework providing some functionalities for example dependency injection. Spring MVC is for creating web projects as you mentioned already. Finally Spring Roo is a tool, that helps you increase productivity, I'd say that instead of manual configuration changes you are using this tool.
Hopefully, this was not too brief...

Can we use Spring MVC Framework and other components of Spring framework (like AOP) together?

I am new to Spring. Just having basic understanding of it.
I am curious to know, can we use Spring MVC Framework and other components of Spring framework (like AOP) together?
Thanks!
Briefly yes.
quote
Spring could potentially be a one-stop shop for all your enterprise applications, however, Spring is modular, allowing you to pick and choose which modules are applicable to you, without having to bring in the rest. You can read details about modules available in Spring Framework.Here

Why to use Spring not JSF (Advantages of spring over JSF)?

i don't know JSF very well, and i have a friend who is using only JSF
and he asked me a very open question, why do you use spring not jsf ?
and because of there are a lot of things about spring in my mind
i wasn't able to give some straight answers
so what are the advantages of spring over JSF ?
Spring and JSF are quite a different frameworks.
JSF is more of a web application framework and you can still use spring with JSF to manage the relationship and creations of the objects.
Spring is more of an entire j2ee application framework/plaform.
Spring MVC and web flow will help you to design web applications similar to JSF.
But spring with its IOC concept also brings a lot of other modules such as dependency injection, aop, DAO, ORM, integration, batch and social tools and much more.
You can also check the JSF-Spring combination - http://www.springsource.org/node/422
JSF is presentation layer, Spring business layer (roughly said), they can be used together and do not compete.
As said before, JSF is a request-driven, MVC web-framework, built around a light-weight IoC container and is designed to simplify and standardize the way UI-layer of a web-application is built.
Spring, on the other hand, is less concerned with UI-layer but its precise definition is hard to formulate. It can be said that the primary function of SF is to tie together different layers of a web application in a standardized way, at the same time abstracting away the implementation details of a particular web technology from the developer. As one of the consequences, the developer is freed from implementing "plumbing" and instead gets working module interconnections which are tested, implemented and used relatively easily. This should provide a boost to productivity and shortens development cycle.
This abstraction can be viewed through various Spring modules - Spring is heavily modularized, so you choose which components of the framework will you be using. Though it features a MVC framework (SpringMVC is mostly written as a reaction to the Jakarta Struts, whom the Spring developers deemed poorly written), Spring lacks a dedicated presentation module so you're free to use most of existing UI technologies (e.g. JSF, GWT-oids, etc.) - once you properly configure them in Spring.
In another words, the "scopes" of JSF and Spring are quite different (though not totally disjunct).

Resources