This is in the company requirement list, I want to know the difference between them - spring

what is the difference between spring core, spring boot, and spring MVC?

In Simple terms,
Spring MVC
Spring - It is a Inversion of control (IOC) and Dependency Injection (DI) framework. Spring helps you develop enterprise applications. Most information you can read here https://spring.io/projects/spring-framework
MVC - It is a design pattern (Model - View - Controller ) MVC , by definition, they are proven patterns and methods to design your application well. We have several design patterns such as Singleton, Factory pattern etc Read more about it here https://refactoring.guru/design-patterns
Spring-boot - It is a library built on top of Spring framework (like we have JARs) which helps develop production ready quick service oriented applications. You can still use typical Spring features. Read more about it here https://spring.io/projects/spring-boot
Spring-core - Just a named terminology representing core features of Spring framework such as IOC container, Dependency Injection, Bean scopes, Autowiring etc
Hope this helps!

Related

Spring MVC modules,subsystems and components

Let's say we have a Spring MVC project which is a banking web application. I am trying to identify the sub-systems ,modules and components of this project.
1.Subsystems - from what I have red the subsystems in MVC architecture are only 3- the Model,View and Controller is that correct?
2.Modules - are these a group of classes that do something particular as a group.For example LoginController.java,RegisterControler.java form a module let's call it Authentication
3.Components - for components I am not sure which they are in a Spring MVC project.
If someone can explain with examples in terms of a banking web application or other Spring MVC app it would be great!
Spring MVC follows the Model-View-Controller design pattern.
Model - A model contains the data of the application. A data can be a single object or a collection of objects.
Controller - A controller contains the business logic of an application. Here, the #Controller annotation is used to mark the class as the controller.
View - A view represents the provided information in a particular format. Generally, JSP+JSTL is used to create a view page. Although spring also supports other view technologies such as Apache Velocity, Thymeleaf and FreeMarker.
Spring Boot Framework has mainly four major Components.
Spring Boot Starters.
Spring Boot AutoConfigurator.
Spring Boot CLI.
Spring Boot Actuator.
Please check out : https://www.journaldev.com/7989/key-components-and-internals-of-spring-boot-framework
In project-specific terms,
Module: It can be something that can be built separately in an application. ex: Login Module, Sign-up module, Transactions module, etc., You can say a module is a group of components.
Sub-systems: As far as I know, subsystems are the service package related stuff.
Components: Annotating a class with #Component tells Spring that it is available for fulfilling injections.
Spring Component annotation is used to denote a class as a Component. It means that the Spring framework will autodetect these classes for dependency injection when annotation-based configuration and classpath scanning is used

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).

Does Grails use Spring Dependency Injection by default

An additional question: What is service layer in Grails app?
Thanks
Yes, Grails uses Spring Dependency Injection by default. Grails is in fact Spring at the core of it all.
Your second question, "what is a service layer" is best described as singleton instances of classes that serve as a layer of abstraction and encapsulation of business logic.

Spring Framework usage

Usually how would each of the module in the Spring framework is used in a web project. I am trying to get an idea about it, as i am on a fast track to learn and implement it.
I know it does have below modules in it, but any help in explaining why and where they are useful would help me a lot in learning.
The Core container module
Application context module
AOP module (Aspect Oriented Programming)
JDBC abstraction and DAO module
O/R mapping integration module (Object/Relational)
Web module
MVC framework module
Thanks,
SS
This page might be helpful to you: Introduction to Spring Framework: Modules. Spring provides a very good, free reference manual that covers much of this and more.
Here's my short summary of why you would use any of these:
Core - This allows you to use the dependency-injection pattern to construct your application, which can greatly simplify your classes and unit testing.
Application Context - This provides support code for many common problems.
AOP - This provides support for Aspect Oriented Programming, which can help you separate "cross cutting concerns" like logging and transaction management from your business logic.
JDBC - Provides support code that makes JDBC easier to use.
OR/Mapping - Provides support code to integrate popular ORM frameworks into Spring.
Web MVC - Provides support for the Model-View-Controller pattern using Spring beans (several other frameworks, such as JSF, provide this as well).
To sum it up, the Core module contains most of what people think of when they think of Spring, and the other modules provide code help you implement your application in a cleaner, more supportable way, without re-inventing the wheel.
The Core container module
Application context module
This is the dependency injection piece - the bean factory and application context where you wire bean dependencies together.
AOP module (Aspect Oriented
Programming)
Cross-cutting concerns like logging, security, transactions, etc. are handled using either Spring interceptors (dynamically generated proxies) or AspectJ (byte code generation).
JDBC abstraction and DAO module
Persistence using a lightweight JDBC template that takes the boilerplate out of using JDBC.
O/R mapping integration module
(Object/Relational)
For folks who prefer Hibernate.
Web module MVC framework module
Web MVC module for JSP, browser based user interfaces based on front controller and view dispatchers.

Resources