There are many people who advised me to use Spring Boot instead of Spring to develop REST web services. I want to know what exactly the difference between the two is?
相关问题
- java.lang.IllegalArgumentException: Cannot set to
- Design RESTful service with multiple ids
- Axios OPTIONS instead of POST Request. Express Res
- Plain (non-HTML) error pages in REST api
- Spring Data MongoDB - lazy access to some fields
相关文章
- java JDK动态代理和cglib动态代理最后获取的代理对象都为null的问题
- 我用scrapy写了一个蛮简单的爬虫怎么封装成一个api啊
- 后端给前端的API接口是怎么用代码写的
- org.xml.sax.SAXParseException; lineNumber: 7; colu
- SpringMVC如何把File封装到Map中?
- Spring: controller inheritance using @Controller a
- How to load @Configuration classes from separate J
- Java spring framework - how to set content type?
Basically, Spring Boot is an opinionated instance of a Spring application.
Spring Boot is a rapid application development platform. It uses various components of Spring, but has additional niceties like the ability to package your application as a runnable jar, which includes an embedded tomcat (or jetty) server. Additionally, Spring Boot contains a LOT of auto-configuration for you (the opinionated part), where it will pick and choose what to create based on what classes/beans are available or missing.
I would echo their sentiment that if you are going to use Spring I can't think of any reasons to do it without Spring Boot.
In short
You can read more here http://projects.spring.io/spring-boot/
Spring Boot is opinionated view of Spring Framework projects.Let's analyse it through one program taken from Spring Boot Documentation.
It's a very basic REST API and you need to add
Spring-boot-starter-web
in yourPOM.xml
for the same. Since you have added starter-web dependency, the annotation@EnableAutoConfiguration
guesses that you want to develop a web application and sets up Spring accordingly.Spring Boot auto-configuration attempts to automatically configure your Spring application based on the jar dependencies that you have added. For example, if
HSQLDB
is on yourclasspath
, and you have not manually configured any database connection beans, then Spring Boot auto-configures an in-memory database.It's opinionated like maven. Maven creates a project structure for you which it thinks is the general pattern of projects like it adds
src/main/java
folder or resource folder for you.Spring boot helps in faster development. It has many starter projects that helps you get going quite faster. It also includes many non functional features like: embedded servers, security, metrics, health checks etc. In short, it makes, spring based application development easier with minimally invading code(Less configuration files, less no of annotations).
Reference: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-documentation-about
Unfortunately and I mean this out of personal frustration with Spring boot, I have yet to see any real quantified list, where the differences are explicitly outlined. There is only qualifications such as the rubbish sentence "...opinionated view..." which are bandied about.
What is clear, is that SpringBoot has wrapped up groups of Spring annotations into its own set of annotations, implicitly. Further obfuscating, and making the need for anyone starting out in SpringBoot to have to commit to memory what a particular SpringBoot annotation represents.
My reply therefore is of no quantifiable benefit to the original question, which is analogous to that of the SpringBoot authors. Those behind Spring IMO deliberately set-out to obfuscate, which reflects the obtuseness of their JavaDoc and API's (see SpringBatch API's as an example, if you think I am flaming) that makes one wonder the value of their open-source ethos.
My quest for figuring out SpringBoot continues.