What is Java Spring Boot?
An intro to Spring Boot—the popular, Java-based tool for developing web apps and microservices
What is Spring Boot?
For any definition of Spring Boot, the conversation has to start with Java—one of the most popular and widely used development languages and computing platforms for app development. Developers all over the world start their coding journey learning Java. Flexible and user-friendly, Java is a developer favorite for a variety of apps—everything from social media, web, and gaming apps to networking and enterprise applications.
Java and the Spring framework
While Java may be easy to use and easier to learn than other languages, the level of complexity to build, debug, and deploy Java apps has escalated to dizzying new heights. This is due to the exponential number of variables modern developers are faced with when developing web apps or mobile apps for common modern technologies such as music streaming or mobile cash payment apps. A developer writing a basic line-of-business app now needs to deal with multiple libraries, plugins, error logging and handling libraries, integrations with web services, and multiple languages such as C#, Java, HTML, and others. Understandably, there is an insatiable demand for any tools that will streamline Java app development, saving the developers time and money.
Enter application frameworks—the large bodies of prewritten code that developers can use and add to their own code, as their needs dictate. These frameworks lighten the developer's load for almost any need—whether they're developing mobile and web apps or working with desktops and APIs. Frameworks make creating apps quicker, easier, and more secure by providing reusable code and tools to help tie the different elements of a software development project all together.
Here's where Spring comes in: Spring is an open-source project that provides a streamlined, modular approach for creating apps with Java. The family of Spring projects began in 2003 as a response to the complexities of early Java development and provides support for developing Java apps. The name, Spring, alone usually refers to the application framework itself or the entire group of projects, or modules. Spring Boot is one specific module that is built as an extension of the Spring framework.
So, with that background on how the Spring framework, Spring Boot, and Java work together, here's the definition of Spring Boot—the tool that streamlines and speeds up web app and microservices development within the Java framework, Spring.
Sometimes, because the language and/or platform is Java, it gets referred to as "Java Spring Boot," the "Java Spring framework," or the "Spring Boot framework." However, because there are other third-party frameworks for Java, such as Play and Hibernate, it's more accurate to say "Spring" and "Spring Boot."
For a high-level discussion of Java basics, check out the article, What is Java?
What's the difference between Spring and Spring Boot?
As mentioned earlier, Spring is an open-source, Java-based app framework that covers many smaller projects under its umbrella. Other popular Spring projects include Spring Data, Spring Cloud, and Spring Security, just to name a few. To understand the difference between Spring Boot vs. Spring, it's important to realize that, even though there may be differences in core capabilities, it's all in the Spring family.
To fully understand the differences between Spring Boot and Spring, we'll need to define a few key terms first.
What are microservices?
Microservices are an approach to software development architecture. The "micro" in microservices refers to code being delivered in small, manageable pieces, or components, and each "service" or core function, is created and deployed independently from the other services. The independent components work together and communicate through prescribed API documents called contracts. The small scale and relative isolation of these microservices has many benefits. For example, because this type of architecture is distributed and loosely coupled, the whole app doesn't break if one component fails. Other benefits are improved productivity, easier maintenance, better business alignment, and greater fault tolerance.
What is dependency injection?
Dependency injection (DI) is a design technique used to achieve inversion of control (IoC). In object-oriented programming like Java, objects that depend on other objects are called dependencies. Typically, the receiving or dependent object is called a client and the object that the client is dependent on is called a service. So, dependency injection passes the service to the client, or "injects" the dependency using code called an injector. DI eliminates the need for the client to specify which service to use—the injector does that work for the client.
What is convention over configuration?
Convention over configuration, sometimes called coding by convention, is a concept used in application frameworks to reduce the number of decisions that a developer has to make. It adheres to the "don't repeat yourself" principle to avoid writing redundant code. Coding by convention strives to maintain flexibility while allowing a developer to only write code for the unconventional aspects of the app they're creating. When the desired behavior of the app matches the conventions established, the app will just run by default without having to write configuration files. The developer will only need to explicitly write configuration files if the desired behavior strays from the "convention."
Spring framework vs. Spring Boot
Because Spring Boot is built on the benefits of the Spring framework, it's not really an "either/or" question of Spring framework vs. Spring Boot, but rather a "both/and" benefit. Spring and Spring Boot go hand in hand:
|What is it?||An open-source web application framework based on Java.||An extension or module built on the Spring framework.|
|What does it do?||Provides a flexible, completely configurable environment using tools and libraries of prebuilt code to create customized, loosely coupled web apps.||Provides the ability to create, standalone Spring applications that can just run immediately without the need for annotations, XML configuration, or writing lots of additional code.|
|When should I use it?||
Use Spring when you want:
Use Spring Boot when you want:
|What's its key feature?||Dependency injection||Autoconfiguration|
|Does it have embedded servers?||No. In Spring, you'll need to set up the servers explicitly.||Yes, Spring Boot comes with built-in HTTP servers like Tomcat and Jetty.|
|How is it configured?||The Spring framework provides flexibility, but its configuration has to be built manually.||Spring Boot configures Spring and other third-party frameworks automatically by the default "convention over configuration" principle.|
|Do I need to know how to work with XML?||In Spring, knowledge of XML configuration is required.||Spring Boot does not require XML configuration.|
|Are there CLI tools for dev/testing apps?||The Spring framework alone doesn't provide CLI tools for developing or testing apps.||As a Spring module, Spring Boot has a CLI tool for developing and testing Spring-based apps.|
|Does it work from an opinionated or unopinionated approach?||Unopinionated*||Opinionated*|
*Opinionated vs. unopinionated framework approach
While the word "opinionated" may sound vaguely negative, both the opinionated approach of Spring Boot and the unopinionated Spring framework have their advantages.
An opinionated approach takes the position that there is one way that is significantly easier than all the others. By design, the software limits designers, encouraging them into doing things in that prescribed way.
It provides a well-paved path, a best practice that will work for most people in most situations. The app is written sticking closely to these best practices and widespread conventions. An opinionated approach makes collaboration and getting help with a coding project much easier—other developers who have experience with that framework will have immediate familiarity with the new app and can jump right in.
An unopinionated approach is adopted if all solutions require roughly the same amount of effort or complexity. It takes the position that there's no one right way to arrive at a solution to a problem. Rather, it provides flexible tools that can be used to solve the problem in many ways. Unopinionated frameworks have the benefit of providing lots of flexibility in development and they put more of the control in developers' hands. The main disadvantage with so much flexibility is that the developer has more decisions to make and may end up having to write more code because the framework is so open-ended and well, unopinionated.
Spring Boot features and benefits
Finally, the exciting part—the core capabilities that Spring Boot provides beyond the Spring framework. Spring Boot gives an easier, quicker path to set up, configure, and run apps. It eliminates the heavy lifting of configuration that is required for setting up most Spring-based apps. Developers can jump right in and use Spring Boot without ever having to learn the underlying Spring framework.
Here's how Spring Boot features help to streamline Java programming tasks. Some key features of Spring Boot are:
- Standalone applications—Spring Boot helps create apps that aren't tied to a specific platform and that can run locally on a device without an internet connection or other installed services to be functional.
- Embedded servers—Spring Boot allows you to embed servers such as Tomcat, Jetty, or Undertow directly.
- Opinionated approach—Spring Boot simplifies build configurations by providing opinionated starter dependencies.
- Autoconfiguration—Spring Boot automatically configures Spring and other third-party libraries whenever possible.
- Production-ready features—Spring Boot provides production-ready features such as metrics, health checks, and externalized configuration.
Benefits of Spring Boot
- Reduces time in development and increases productivity—Spring Boot makes it much easier to develop Spring-based apps with Java. Its opinionated approach to the Spring framework decreases the time spent on decisions and repetitive tasks and frees up time to focus on creating and testing the apps.
- Decreases the need to write boilerplate code, annotations, and XML configuration—There's no need for developers to generate code or configure XML or even learn the Spring framework, if they don't want to.
- Integrates apps in the Spring project family—Spring Boot apps integrate seamlessly with other projects in the Spring framework ecosystem—such as Spring Data, Spring Cloud, Spring Security—as well as with other trusted cloud services such as Microsoft Azure Spring Cloud.
- Provides dev/test tools—With Spring Boot's command-line interface (CLI) tool and embedded HTTP servers, it makes it very simple to create environments to dev/test Spring-based apps.
- Offers plugins and tools to make development easier—Spring Boot offers plugins to be able to work with in-memory databases, as well as other popular build automation tools such as Apache Maven.
Java Spring Boot tutorials
If you're already familiar with building apps using the Spring framework, you'll probably find it straightforward to learn Spring Boot using the tutorials, project starters, and documentation provided in this section. But here's some good news if you're in a hurry to use Spring Boot but don't know the framework yet: It's possible to learn—and work with—Spring Boot before learning the Spring framework because you'll pick up many of the framework fundamentals as you go along. While this won't teach you everything there is to know about the framework, it will give you a good head start if you decide to learn it later on.
Another benefit of learning Spring Boot, besides making app development much faster and more efficient, is that it also sets you up to be able to use other Spring capabilities, namely Spring Data, Project Reactor, and Spring Security.
That said, you'll find it easier to work through your first Spring Boot tutorial if you first learn how the basic concepts of dependency injection and inversion of control work in the Spring framework. Here's a very high-level overview:
- XML-based, i.e., <beans/> and <namespace:*/>
- Annotation-based, i.e., @Component, @Autowired, @Inject
- Java-based, i.e., @Configuration classes, @Bean methods
Inversion of control (IoC)
- ApplicationContext—the root interface that serves as the Spring IoC container
- BeanFactory—the interface to access the Spring container
- Beans—the objects instantiated, assembled, and managed by ApplicationContext
Spring Boot tutorials for beginners
Once you've mastered the basics, if you're looking to build and deploy Spring Boot apps at scale, consider checking out the fully managed Azure Spring Cloud service from Microsoft and VMware.
Create and help secure a Java app
Create a Java app with the Spring Initializr using the Spring Boot starter for Azure Active Directory (Azure AD).
Deploy your first app to Azure Spring Cloud
Learn to create, provision, and monitor a simple Spring Boot app built with Spring Initializr.
Build a simple Spring Boot microservice
Build and deploy a simple microservice—and then learn to add Spring Cloud technologies to it.
More Spring Boot starters
Add storage, security, authentication, and key vault features to your Spring Boot apps.
Spring Boot is an open-source, microservice-based Java web framework offered by Spring, particularly useful for software engineers developing web apps and microservices.
"Spring Boot in Java" is another way of saying "Java Spring Boot"—the two terms can be used interchangeably. Java is the language and platform, Spring is the application framework based on Java, and Spring Boot is an extension of the Spring framework, with some added benefits.
Spring Boot has the functionality of the general Spring framework, but Spring Boot doesn't require you to learn Spring. A developer can get an app up and running with less time because Spring Boot attributes are autoconfigured and the opinionated approach removes much of the boilerplate code and configuration involved with Spring app development and deployment.
Reduced development time, increased productivity, and ease of use are just a few of the benefits of developing Spring Boot apps.
There are lots of tutorials, quickstarts, and documentation on the Spring website as well as Spring Boot Starters and documentation from Microsoft Azure. If you'd like to get started right away deploying Spring Boot apps, check out the webinar, Accelerate Spring Boot Applications to Cloud at Scale.