-4

I want to ask about Spring Boot and Spring MVC.

  1. What is the difference between these components and when should I use them?
  2. How can I use Spring MVC to generate entities from a database?
scopchanov
  • 7,966
  • 10
  • 40
  • 68
mohamed essam
  • 19
  • 1
  • 10
  • spring boot is a tool for starting spring applications quickly. spring mvc is a model view controller framework. – Elliott Frisch Aug 22 '18 at 00:03
  • I don't know why people give negative without explaining! I don't see anything wrong with this question! – Junaed Sep 02 '20 at 14:11

2 Answers2

2

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.

KyleM
  • 4,445
  • 9
  • 46
  • 78
1

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:

  1. Create a Plain Old Java class with getters and setters (methods like getXXX and setXXX).
  2. Annotate the class with @Entity
  3. 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

Yserbius
  • 1,375
  • 12
  • 18