我刚刚开始学习春天。在我的下一步,我想开发更大的网络应用程序。
现在我想知道我是否应该从Spring Boot或Spring MVC开始。我已经读了一些东西,但这是令人困惑的,因为两者看起来相似。
那么两者之间有什么不同呢?
我刚刚开始学习春天。在我的下一步,我想开发更大的网络应用程序。
现在我想知道我是否应该从Spring Boot或Spring MVC开始。我已经读了一些东西,但这是令人困惑的,因为两者看起来相似。
那么两者之间有什么不同呢?
当前回答
使用spring引导,您将不需要构建配置。这将在您创建项目时自动完成。 如果你使用spring MVC,你需要自己构建配置。它更复杂,但也至关重要。
其他回答
简单来说,它可以表述为:
Spring boot = Spring MVC +自动配置(不需要编写Spring .xml文件进行配置)+服务器(您可以有嵌入式Tomcat, Netty, Jetty服务器)。
Spring Boot是一个opiniated框架,因此它的构建考虑到了开发速度快,配置时间短,并且有很好的社区支持。
这样想:
Spring MVC是一个基于web实现MVC架构的框架。
Spring Boot是一个面向程序员的工具。程序员必须专注于编程,工具必须专注于配置。所以我们不需要浪费时间配置一堆xml来创建一个简单的“Hello world”。
以下是区分Spring、Spring MVC和Spring Boot的一些要点:
春天:
Main Difference is "Test-ability". Spring come with the DI and IOC. Through which all hard-work done by system we don't need to do any kind of work(like, normally we define object of class manually but through Di we just annotate with @Service or @Component - matching class manage those). Through @Autowired annotation we easily mock() it at unit testing time. Duplication and Plumbing code. In JDBC we writing same code multiple time to perform any kind of database operation Spring solve that issue through Hibernate and ORM. Good Integration with other frameworks. Like Hibernate, ORM, Junit & Mockito.
Spring MVC
Spring MVC框架是Spring的一个模块,它为面向HTTP的web应用开发提供了便利。 Spring MVC在输入逻辑(控制器)、业务逻辑(模型)和UI逻辑(视图)上有明确的代码分离。 Spring MVC模式有助于开发灵活和松散耦合的web应用程序。 根据您的需要,提供各种硬编码方式来定制您的应用程序。
Spring Boot:
Create of Quick Application so that, instead of manage single big web application we divide them individually into different Microservices which have their own scope & capability. Auto Configuration using Web Jar : In normal Spring there is lot of configuration like DispatcherServlet, Component Scan, View Resolver, Web Jar, XMLs. (For example if I would like to configure datasource, Entity Manager Transaction Manager Factory). Configure automatically when it's not available using class-path. Comes with Default Spring Starters, which come with some default Spring configuration dependency (like Spring Core, Web-MVC, Jackson, Tomcat, Validation, Data Binding, Logging). Don't worry about versioning issue as well.
(演化类似:Spring -> Spring MVC -> Spring Boot,所以新版本兼容旧版功能。) 注:它不包含所有点。
补充一点,Java Spring是一个框架,而Java Spring Boot是附加的,通过提供预配置和易于使用的组件来加速它。 总是建议在跳到Java Spring Boot之前了解Java Spring的基本概念。
Without repeating the same thing in previous answers, I'm writing this answer for the people who are looking to starting a new project and don't know which is the best framework to startup your project. If you are a beginner to this framework the best thing I prefer is Use spring boot(with STS /Spring Tool Suite). Because it helps a lot. Its do all configurations on its own. Additionally, use Hibernate with spring-boot as a database framework. With this combination, your application will be the best. I can guarantee that with my experiences.
即使这是JEE(目前)最好的框架之一,但在不久的将来它也会消亡。有一些轻量级的替代品即将问世。所以要不断更新你的经验,不要拘泥于一个特定的框架。最好的事情是精通概念,而不是框架。