目标
为了介绍spring boot的简单入门,而且讲明白为什么要使用它,它的特点。
手段
通过介绍spring boot的发展历史,诞生当时的历史现状,诞生的原因,发展,来说明
资料
官方简介:
Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”. We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.
Features
- Create stand-alone Spring applications
- Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
- Provide opinionated ‘starter’ POMs to simplify your Maven configuration
- Automatically configure Spring whenever possible
- Provide production-ready features such as metrics, health checks and externalized configuration
- Absolutely no code generation and no requirement for XML configuration
Spring的发展情况
When Spring 1.0 hit the scene, it completely changed how we develop enterprise Java applications. Spring dependency injection and declarative transactions meant no more tight coupling of components and no more heavyweight EJB s. It couldn’t get any better.
With Spring 2.0 we could use custom XML namespaces for configuration, making Spring itself even easier to use with smaller and easier to understand configuration files. It couldn’t get any better.
Spring 2.5 gave us a much more elegant annotation-oriented dependency-injection model with the @Component and @Autowired annotations, as well as an annotation-oriented Spring MVC programming model. No more explicit declaration of application components, and no more subclassing one of several base controller classes. It couldn’t get any better.
Then with Spring 3.0 we were given a new Java-based configuration alternative to XML that was improved further in Spring 3.1 with a variety of @Enable -prefixed annotations. For the first time, it become realistic to write a complete Spring application with no XML configuration whatsoever. It couldn’t get any better.
Spring 4.0 unleashed support for conditional configuration, where runtime decisions would determine which configuration would be used and which would be ignored based on the application’s classpath, environment, and other factors. We no longer needed to write scripts to make those decisions at build time and pick which configuration should be included in the deployment. How could it possibly get any better?
spring boot起源
Spring的jira上提的需求,揭示了spring boot的起源
https://jira.spring.io/browse/SPR-9888
描述:
As the enterprise development landscape grows more diverse the simpler the application framework the more likely developers are to adopt the framework. Developers with existing knowledge of previously common frameworks like the Servlet container are becoming more rare. Spring’s dependence on frameworks and containers outside of Spring’s component model increases the learning curve of new developers attempting to create and maintain spring web applications.
Traditionally Spring web applications have been embedded in a servlet container. This was useful in the past when the majority of enterprise applications ran in and depended on the servlet container for deployment and configuration. However, a servlet container comes with learning curve that we cannot assume new developers will have already overcome. The learning curve includes things such as:
web.xml and other Servlet oriented configuration concepts
.war directory structure
Container implementation specific items (e.g. ports, thread pools, etc.)
Complex Classloading hierarchies
Monitoring and management facilities configured outside of the application
Logging facilities
Configuration of application context roots
So forth
All of the above items are configured in inconsistent non-unified ways requiring a development team to learn these for the container their using in addition to Spring’s own configuration model.
I think that Spring’s web application architecture can be significantly simplified if it were to provided tools and a reference architecture that leveraged the Spring component and configuration model from top to bottom. Embedding and unifying the configuration of those common web container services within a Spring Container bootstrapped from a simple main() method.
Though there are many frameworks and platforms today that no longer require a container I think inspiration can be drawn most from DropWizard (http://dropwizard.codahale.com/).
Another project I’ve seen inspired by DropWizard but leveraging Spring is HalfPipe (https://github.com/32degrees/halfpipe). Though I don’t think HalfPipe goes far enough. I think to truly provide simplification the entire architecture, wherever reasonable, must be embedded within the Spring container rather than without. Though it does have several other interesting ideas.
I believe that a Spring driven containerless web application architecture could provide benefits like:
Provide a single unified component model requiring no knowledge of the Servlet Component models.
Unified configuration of everything allowing developers to only have to learn one Spring configuration model for both component and app configuration.
Execution from a void main will simplify application startup and shutdown.
A much simpler pure java classloading hierarchy.
Simpler development tooling. Instead of needing a complex IDE to construct a war and deploy it to a dev container simply execute the applications Main class.
For such an architecture to be successful this architecture will also need new and simple ways to configure common Spring tools, such as Spring MVC and Spring Security, that have traditionally been configured through the servlet container.
To accomplish this simplification I don’t think Spring would need to create a brand new http engine. It could simply utilize an embedded servlet container like Jetty. Though it would need to abstract away as much configuration as possible.
I think a reference app would also be unnecessary to set an example of how to structure, develop and configure such an application in a pure spring manner.
翻译描述:
开发人员越来越多的采用更简单的框架。会以前通用框架的相关知识,像Servlet容器的开发者越来越少了,Spring应用以来容器,提高了新的开发者尝试创建和使用spring web 应用。
传统spring web应用嵌入在servlet容器中。大多数企业应用的部署和配置,依赖和运行在servlet容器上,这在过去是有效的。
然而,一个servlet容器自带的学习曲线,我们不能承担新的开发者已经克服。
学习曲线包含:
- web.xml和其他 Servlet面向配置的概念
- .war目录结构
- 容器内具体的项目(端口,线程池等)
- 复杂的类加载结构
- 监控和管理设施要配置的应用程序之外
- 日志设施
- 应用上下文根配置
8.等等
上述所有项目都在要求开发团队学习这些他们除了使用Spring的自己的配置模型容器不一致的不统一配置方式。
我认为Spring的web应用程序架构可以显著简化,如果它是提供工具和参考架构 从上到下的连通Spring组件和配置模型。嵌入和统一的配置 这些共同Web容器服务的配置 可以从Spring容器一个简单的main()方法中的。
我相信,一个Spring驱动无容器的Web应用架构可以提供下列好处:
- 提供一个统一的组件模型,无需在Servlet组件模型的知识
- 人的一切都允许开发统一的配置,只需要学习一种Spring配置模型为组件和应用配置。
- 用从一个空的main简化应用程序的启动和关闭。
- 一个更简单的纯Java类加载层次
- 更简单的开发工具。而不是需要一个复杂的IDE来构建一个战争并将其部署到一个开发容器只需执行应用程序主类。
对于这样的体系结构,为了成功这个架构也需要新的和简单的方式来配置公共Spring工具,如Spring MVC和Spring Security,即传统上一直通过servlet容器构造。
要做到这一点简单化,我不认为Spring需要创建一个全新的HTTP引擎。它可以简单地利用像Jetty一个嵌入式servlet容器。尽管这将需要抽象掉尽可能多的配置成为可能。
我想引用的应用程序也将是不需要设置如何构建一个例子,开发和配置在纯Spring的方式这样的应用程序。
可以看出,spring为了实现无容器依赖,减小开发者的学习曲线,更快的开发web应用,开发出了spring boot,spring boot就是为了简化web开发体验。