does spring provide 2 mvc platforms, grails and spring mvc? - java

Just reading spring in action, and I know there is a chapter on MVC that I havent' got to yet.
I also read about grails, is that another framework or built on top of spring?

Yes, Grails is built on Spring (and several other frameworks) and it uses Spring MVC to implement its MVC layer.

Related

Differences between Spring Boot & Spring MVC [duplicate]

This question already has answers here:
Difference between Spring MVC and Spring Boot [closed]
(11 answers)
Closed 4 years ago.
I want to ask about Spring Boot and Spring MVC.
What is the difference between these components and when should I use them?
How can I use Spring MVC to generate entities from a database?
You can use spring boot to embed a web server into your JAR. So basically you can run a single command (e.g. java -jar yourSpringBoot.jar) and it will start up the embedded web server and listen on whatever port you configured in the application properties file. Spring MVC is a framework, it allows you to build web applications.
For the database question, I would recommend reading about Hibernate and its spring boot integration.
Spring Boot is a framework for running enterprise applications using a simple, all-in-one tool that can configure, build, and run an application.
Spring MVC is a framework for building said application. It is used to create Web application API endpoints, visualizations, database entities, and other stuff. You can configure and run it with Spring Boot or just use the standard Spring configuration system.
If you want to map entities to a database, you can use Spring MVC and Spring Boot. There are plenty of tutorials online, but the basics is like this:
Create a Plain Old Java class with getters and setters (methods like getXXX and setXXX).
Annotate the class with #Entity
Ensure that Spring recognizes that package as containing entities. This can be done with Spring Boot by default when you annotate your Application class with #EnableAutoConfiguration
https://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html

Spring and Spring MVC -- are they two different framework?

As I am trying to learn some framework J2EE, I am studying on spring framework.
The thing that confused me in some tutorial they mention Spring MVC as a part of the spring framework. But at some place they mentioned as like a different and independent framework. some people even compare Spring MVC with Struts (which is another framework as i understand ).
Now how actually should i take Spring MVC in mind as a different framework like Struts or as a part of Spring?
Spring has incredibly grown in the last decade, so nowadays the single word Spring means different things depending on the context in which it is used. In such context might be used the following Spring projects.
One of these projects is the Spring Framework: an open source application framework and inversion of control container for the Java platform which offers lots of features:
Dependency Injection
Aspect-Oriented Programming including Spring's declarative transaction management
Spring MVC web application and RESTful web service framework
Foundational support for JDBC, JPA, JMS
Much more...
each one of these features is designed in a Spring Framework's module grouped in layers, so among others, you can find:
in the core layer
The Core and Beans modules provide the fundamental parts of the framework, including the IoC and Dependency Injection features.
...
...
in the web layer
...
The Web-Servlet module contains Spring' s model-view-controller (MVC) implementation for web applications. Spring's MVC framework provides a clean separation between domain model code and web forms, and integrates with all the other features of the Spring Framework.
...
..
Your question
Now how actually should i take Spring MVC in mind as a different framework like Struts or as a part of Spring?
Both are right because of what summarized above: Spring includes Spring Projects and one of them is Spring Framework which contains Spring's MVC framework.
So if you think the single word Spring both as the most general and as the Spring Framework, Spring MVC is part of Spring.
Moreover you may consider Spring MVC like Struts, because Spring's MVC framework application domain is extremely closed to the Struts one.
I think your confusion comes up from considering a part (Spring's MVC framework) as different from the whole (the most general single word Spring or the Spring Framework) in which the part may be thought included.
Spring in common meaning is framework provided by spring-core artifact [http://mvnrepository.com/artifact/org.springframework/spring-core]. Contains IoC, Dependency Injections and other stuff.
Spring MVC using Spring to bootstrap application context, and add some functionality and features specified to MVC. You should think about Spring MVC as 'plugin' or 'extension' of Spring.
Spring is a Java EE-like stack. The core Spring framework provides Dependency injection, AOP, JDBC helpers etc. Also there are a couple of sub-projects: Spring MVC, Spring batch, Integration etc. (See the full stack here: http://spring.io/projects)
Yes Spring MVC is veri similar to Struts, as both are action oriented MVC frameworks. Usually the sub-projects depend on the core and not on the other sub-projects.
The main point is that Spring is a stack of technologies.

what is the difference between Spring and Spring MVC framework

I am new to Spring. Can any one let me know what is the difference between Spring and Spring MVC Framework ?
Spring is a big framework, that contains a lot of components. One of these components is Spring MVC - it is a component that lets you implement your web application according to the model-view-controller design pattern.
1- Spring in abstract word is a framework
The Spring Framework is an open source application framework and inversion of control container for the Java platform.
Check this links for more information:
Spring Framework
Framework vs. Toolkit vs. Library
2- MVC architecture
it is an architecture that help the developer to separate the building block of web application.
Model View Controller or MVC as it is popularly called, is a software design pattern for developing web applications
check this link for more information:
Basic MVC Architecture
MVC is a Spring module. You use it for designing web applications. MVC in Spring implements the front controller design pattern. In your web.xml you'll define a single servlet (DispatcherServlet) and all your requests will pass through it and will be attended by Controllers you will define (#Controller).
Spring is a framework which helps to connect different components together. There are many modules for IOC, AOP, Web MVC etc.Spring Framework is an open source application framework and inversion of control container for the Java platform.
Spring MVC (Model–view–controller) is one component within the whole Spring Framework, to support development of web applications.
Spring MVC is one component within the whole Spring Framework, to support development of web applications. You can use any web containers, so it works fine with Tomcat. Just think that Spring is a third party library. You just need to put the necessary jar files in the lib directory, and define a few xml files.
So basically when you just say Spring it is a just a framework. And by framework I mean lot of functionalities/jars. Like you may have core which has core functionality or aspectj etc. Spring MVC i.e model view controller is one such functionality offered by Spring framework. You can deffer processing of request to various controllers based on the pattern of URL requested. You can refer
Spring MVC hello world example
Spring framework can be visualized as an alternative to, replacement for, or even addition to the Enterprise JavaBeans (EJB) model as mentioned here. That means a framework to develop distributed, scalable, secured, transactional application.
Spring MVC can be thought of as an replacement to Struts, Stripes, Tapestry etc, i.e. Presentation layer framework.
Spring framework is the super set of Spring MVC.
Spring
An umbrella term to denote various projects, one of which is Spring Framework.
Spring MVC
The Spring Framework project has several features. One of them is Spring MVC.
Features of Spring Framework are -
Core Technologies: Dependency Injection, validation, data binding, type conversion, SpEL, AOP etc.
Testing
Data Access: Transactions, DAO support, JDBC, ORM etc.
Spring MVC and Spring WebFlux web frameworks.
Integration: JMS, JMX, email, scheduling etc.
Languages: Kotlin, Groovy, dynamic languages.
So, the Spring MVC feature allows developers to build applications following Model-view-controller design pattern using Spring Framework.
Other Spring projects
Spring Boot: For creating stand-alone Spring applications using Convention over configuration design paradigm.
Spring Data: For creating Spring-based programming model for data access. It has various modules like Spring Data JDBC, Spring Data JPA, Spring Data MongoDB etc.
Spring Security: Powerful and highly customizable authentication and access-control framework for both Authentication and Authorization.
And many other projects.
NOTE
Spring, Spring Framework and Spring MVC these terms are often used interchangeably among developers which sometimes creates confusion for people who already don't know the details.

Can i learn Spring MVC directly for web sites rather than basic Spring

Firstly, I want to know is Spring and Spring MVC different things.
IF they are different then can I jump directly to Spring MVC because I want to build website
and I have very less time to experiment and I want to start as soon possible.
Will spring MVC is sufficient without using hibernate or anything which I need to learn.
I know only core Java.
Spring MVC builds on top of Spring. So you need to know basics of Spring to use Spring MVC. And you doesn't need to learn Hibernate.
Spring
Introduction to Spring
Read chapters 1, 2 and 3 from reference manual
Spring MVC
Spring MVC step by step

What are all the portlet classes in Spring mvc?

In Spring MVC there seem to be two parallel class hierarchies, one with portlet, one without.
What is that? Why is it so and what should I use.
That's because
In addition to supporting conventional
(servlet-based) Web development,
Spring also supports JSR-168 Portlet
development. As much as possible, the
Portlet MVC framework is a mirror
image of the Web MVC framework, and
also uses the same underlying view
abstractions and integration
technology.
The Spring documentation (Chapter 16. Portlet MVC Framework) provides more information about the differences.
To answer your last question: you should use the Portlet MVC framework if you are developing portlets (web applications to be deployed in a portal). If you are developing conventional web applications you should use the Web MVC framework.
You mean as opposed to servlet? The portlet MVC framework is specifically for development of JSR-168 (maybe JSR-286 too? not sure) portlets. There is a separate portlet hierarchy because the portlet MVC workflow differs from the servlet MVC workflow.
If you're developing a portlet, you want the portlet MVC framework. Otherwise, the Servlet MVC framework is what you need and you don't need to worry about the portlet stuff.

Categories